夏泽良,碘钟反应,阿屁虎
后,看了下zend framework配置操作数据库,php教程如下:
在application/configs的文件下建立一个config.ini文件
配置信息如下:
[general]
db.adapter=pdo_mysql
db.config.host=localhost/iparess
db.config.username=username
db.config.password=password
db.config.dbname=databasename
2、
在pulibc 目录的index.php页面中
/** zend_application */
require_once 'zend/application.php';
的下面插入
//set the datase config
require_once 'zend/config/ini.php';
require_once 'zend/registry.php';
require_once 'zend/db.php';
require_once 'zend/db/table.php';
$config=new zend_config_ini('./../application/configs/config.ini',null, true);
zend_registry::set('config',$config);
$dbadapter=zend_db::factory($config->general->db->adapter,$config->general->db->config->toarray());
$dbadapter->query('set names utf8');
zend_db_table::setdefaultadapter($dbadapter);
zend_registry::set('dbadapter',$dbadapter);
就此,我就用我的本地wordpress数据库来测试下,就用wp_posts表来测试吧:
首先模型models建立wp_posts.php
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
YII2框架中使用RBAC对模块,控制器,方法的权限控制及规则的使用示例
YII2框架中ActiveDataProvider与GridView的配合使用操作示例
PhpStorm的使用教程(本地运行PHP+远程开发+快捷键)
网友评论