1配置文件中配置另一数据库连接信息
例如:
\'TestModelConfig\' => array(
//\'配置项\'=>\'配置值\'
\'DB_TYPE\' => \'mysql\', // 数据库类型
\'DB_HOST\' => \'localhost\', // 服务器地址
\'DB_NAME\' => \'test\', // 数据库名
\'DB_USER\' => \'root\', // 用户名
\'DB_PWD\' => \'root\', // 密码
\'DB_PORT\' => \'3306\', // 端口
\'DB_CHARSET\' => \'utf8\',
\'DB_PREFIX\' => \'\', // 数据库表前缀
)
2 创建一个新的model
3 new 出这个model 例如:$testModel = new \Home\Model\TestModel(\'test\',\'jacky_\',\'TestModelConfig\');//test =>表名,jacky_=>表前缀,TestModelConfig=>数据库连接参数;
4 通过这个对象对test表进行操作。