Ok, here is the scenario.
I have two or more database schemas on the same database server, all have the same structure but different data.
One database account which has the required privileges on all those schemas.
I want to change the schema used in the Application without creating/connecting to more DBConnections.
Especially for usage in Active Records.
So with the same model, I want to access Schema A, B, C…
which all are on the same machine, without creating additional connections.
I know it is easy and possible if I use Data Access Objects (DAO)
and then specify the Schema used as such:
$sql="INSERT INTO SchemaA.TableA (mycol) VALUES(:myval)";
$command=Yii::app()->db->createCommand($sql);
and with the same connection on SchemaB:
$sql="INSERT INTO SchemaB.TableA (mycol) VALUES(:myval)";
$command=Yii::app()->db->createCommand($sql);
BUT with Active Records the only way I know is the one in the Guide
http://www.yiiframework.com/doc/guide/1.1/en/database.ar
Which states:
This requires though a new connection to the Database,
an overhead which should be avoided since its not required…
Please provide your ideas on the subject or solutions.
Perhaps I am looking in the wrong direction;