我的一个项目分组需要操作两个数据库,配置文件可以配置两个数据库吗?
回复内容:
我的一个项目分组需要操作两个数据库,配置文件可以配置两个数据库吗?
可以的。
http://document.thinkphp.cn/manual_3_2.html#connect_db
http://document.thinkphp.cn/manual_3_2.html#switch_database
6本文来源gao@dai!ma.com搞$代^码!网7
搞gaodaima代码
可以配置,在需要连接到不同数据库时传入对应config即可
请看官方文档:
http://document.thinkphp.cn/manual_3_2.html#connect_db
可以使用M()函数,例如$model = M(‘test’, ”, ‘mysql://root:1234@localhost/demo#utf8’);
可以随时切换数据库,方法其他人都说了