I have two scemas, with an User model. Both contents are different.
In my controller, I have this:
self::$db = 'db1';
echo '<pre>';
var_dump (User::find()->toArray());
echo '</pre>';
self::$db = 'db2';
echo '<pre>';
var_dump (User::find()->toArray());
echo '</pre>';
in my Model:
class User extends Model
{
public function getSource()
{
return "users";
}
public function getSchema()
{
echo IndexController::$db.';<br>';
return IndexController::$db;
}
}
(I know its dirty, I change it via static variable)
Interestingly it echoes:
db1;
db1;
db1;
(here goes the records from db1)
db2;
db2;
(here goes the records from db1 INSTEAD OF db2!)