Dynamic db connections

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

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.

It solves the problem?

Because i’m trying to do something similar…