zend framework - Switching db connection in Doctrine models -


i'm researching zend+doctrine performance on existing shard database system. of application models connect main database (db1) whilst models need dynamically connect different databases (db2, db3 etc.)

of models connect different database, need easy way switch connection. there method in doctrine_record can override provide new connection instance?

no need override anything. simple create many connections need (per default, should have 1 connection has name, have n connections different names.

$conn1 = doctrine_manager::connection('mysql://username:password@localhost/database1', 'connection1'); $conn2 = doctrine_manager::connection('mysql://username:password@localhost/database2', 'connection2'); 

different models can bound different connections. put them in base models.

doctrine_manager::connection()->bindcomponent('your_model', 'connection1'); 

alternatively, can use method of connection manager

setcurrentconnection('connection1') 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -