Change Schema without making a new DBConnection

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)";


and with the same connection on SchemaB:

$sql="INSERT INTO SchemaB.TableA (mycol) VALUES(:myval)";


BUT with Active Records the only way I know is the one in the Guide

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;

Any ideas?

At least if someone is sure that there is no other way than the above, please say so.

Hi, I’m not sure it’s what you need, but have you seen this thread, and in particular this post?

It does not help my case.

I need to change Schema without making a new DB connection.

I see no point in making new connections since my DB User has privileges on all those Schemas and they are on a single Machine.

Also, I need to use it in Active Records…

Thanks though.