We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

getSchema() has no effect

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!)


1.3k

you might have a metadata caching to file



28.1k

hmm ok, and how to get rid of the cahe?