jackylee92

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表进行操作。

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-06-14
  • 2021-08-08
  • 2021-08-08
  • 2021-06-11
  • 2022-03-05
  • 2022-12-23
  • 2021-09-29
猜你喜欢
  • 2021-11-11
  • 2021-11-11
  • 2021-06-16
  • 2021-11-11
  • 2021-11-11
  • 2021-07-25
  • 2021-12-06
相关资源
相似解决方案