Multiple Connection Dilemma

Hello all,

I’m having a bit of a dilemma regarding connections. Here is my scenario.

I’ve looked at this CDynamicRecord but have a couple of questions.


I have 2 databases, both have identical schemas, the only thing that is different is the information itself on the tables’s rows.

Lets say, for example purposes, the user has a menu saying "Go to App1" and other saying "Go to App2" and the data is lazy loaded.

When USER1 clicks "Go to App1", he is redirected to a page that has a gridview containing 100 records, showing 10 records in each page, and the user is viewing the first page.

In the mean time, another user, USER2, logs in and clicks "Go to App2". In the same way as before, a gridview is presented showing the first 10 records.


1 - If USER1 clicks "Next Page", will he see the data from the App1 database or the rows will display data from the App2 Database?

2 - If the data was eager loaded and there where a million records, if USER1 clicks "Go to App1" and after 0.1 seconds USER2 clicks "Go to App2", will the data flow be interrupted?

How can I make sure once the user clicks "Go to App1", the rest of the operations done inside App1 will affect the correct database all the way, despite of other users overriding the DB Connection?

In short, how can I make a model named "Product" refer to the correct database (without having to create two models) despite of the overriding methods?

Thank you in advance,


Solved by overriding getDbConnection() method in model.