Multiple Databases with the same Model


(Rotlaus) #1

For a new application we are looking for a php web framework that supports multiple databases with the same schema/model. Every customer of us will become his own webserver with his own database. On top of this we want to develop a central administration app that works on all customer databases, which are all have the same schema/model. Does Yii support such a thing? If not, would it be easy to add this to the current Database/Active Record functionality?


(Jerry2801) #2

you can add function in your model like:


public function getDbConnection()

{

    return Yii::app()->user->getState('myDbConnectionId');

}


(Riccardo Roasio) #3

But how can i set myDbConnectionId dynamically so that every time i can specify the db to be used?