让人郁闷的Zend_Application_Resource_Multidb
Zend_Application_Resource_Multidb类主要用于有多个数据库的系统 。
今天有需要用到了。但是其配置却让人有一点点郁闷。
平时用的是Zend_Application_Resource_Db类。其数据库配置信息,是这样子写的:
1 resources.db.adapter = "pdo_access"
2 resources.db.param.adapterNamespace = "Szgit_Db_Adapter"
3 resources.db.param.driver = "{microsoft access driver (*.mdb)}"
4 resources.db.param.dbq = "e:/db/csdb.mdb"
5 resources.db.param.uid =
6 resources.db.param.pwd = "123456"
7 resources.db.param.dbname = ""
8 resources.db.param.password = ""
9 resources.db.param.username = ""
改成Zend_Application_Resource_Multidb,想当然的只要改一下资源类就可以了吧,于是写成这样:
resources.multidb.db1.adapter = "pdo_access"
resources.multidb.db1.param.adapterNamespace = "Szgit_Db_Adapter"
resources.multidb.db1.param.driver = "{microsoft access driver (*.mdb)}"
resources.multidb.db1.param.dbq = "e:/db/csdb.mdb"
resources.multidb.db1.param.uid =
resources.multidb.db1.param.pwd = "123456"
resources.multidb.db1.param.dbname = ""
resources.multidb.db1.param.password = ""
resources.multidb.db1.param.username = ""
= "pdo_access"
resources.multidb.db2.adapter
resources.multidb.db2.param.adapterNamespace = "Szgit_Db_Adapter"
resources.multidb.db2.param.driver = "{microsoft access driver (*.mdb)}"
resources.multidb.db2.param.dbq = "e:/db/csdb2.mdb"
resources.multidb.db2.param.uid =
resources.multidb.db2.param.pwd = "123456"
resources.multidb.db2.param.dbname = ""
resources.multidb.db2.param.password = ""
resources.multidb.db2.param.username = ""
但事实上这样写是错误的。Zend_Application_Resource_Multidb类的数据库适配器参数不需要写param,应该要这样写:
resources.multidb.db2.adapter = "pdo_access"
resources.multidb.db2.adapterNamespace = "Szgit_Db_Adapter"
resources.multidb.db2.driver = "{microsoft access driver (*.mdb)}"
resources.multidb.db2.dbq = "e:/db/csdb2.mdb"
resources.multidb.db2.uid =
resources.multidb.db2.pwd = "123456"
resources.multidb.db2.dbname = ""
resources.multidb.db2.password = ""
resources.multidb.db2.username = ""
这就有一点点让人郁闷了。同样是配置数据库。写法却不相同。