Hey all,
I need to dynamically change between several (large amount of) db connections.
From what i can see in the documentation, i need to override the getDbConnection() function of each model but the main problem here is that a model doesn't exclusively belong to a db connection, i.e. a model represents a table that exists in several (if not all) databases.
Any ideas on what i should do?
Thanks in advance
Page 1 of 1
Dynamic db connections
#2
Posted 13 July 2009 - 12:05 PM
I'm not sure this would solve your problem, but give this a thought.
Extend CActiveRecord::model() so it takes a parameter indicating a db connection. Before returning parent::model() implementation, it sets the corresponding connection to a protected property.
Make sure CActiveRecord::getDbConnection() will find it.
Extend CActiveRecord::model() so it takes a parameter indicating a db connection. Before returning parent::model() implementation, it sets the corresponding connection to a protected property.
Make sure CActiveRecord::getDbConnection() will find it.
#3
Posted 03 March 2010 - 10:30 AM
It solves the problem?
Because i'm trying to do something similar...
Because i'm trying to do something similar...
pestaa, on 13 July 2009 - 12:05 PM, said:
I'm not sure this would solve your problem, but give this a thought.
Extend CActiveRecord::model() so it takes a parameter indicating a db connection. Before returning parent::model() implementation, it sets the corresponding connection to a protected property.
Make sure CActiveRecord::getDbConnection() will find it.
Extend CActiveRecord::model() so it takes a parameter indicating a db connection. Before returning parent::model() implementation, it sets the corresponding connection to a protected property.
Make sure CActiveRecord::getDbConnection() will find it.
Share this topic:
Page 1 of 1

Help
This topic is locked











