Hi.
I use PostgreSQL as my application's database server, but the database adapter I create don't set the schema for the models and I need to do it manually using the models manager, how can I avoid setting the schema manually for every model?
This is how I'm creating the Adapter
my database config:
'database' => [
'host' => 'localhost',
'username' => 'username',
'password' => 'password',
'name' => 'mydbname',
'schema' => 'app'
],
db connection in my app bootstrap:
// Database
$di->set('db', function () use ($config) {
return new Phalcon\Db\Adapter\Pdo\Postgresql(array(
'host' => $config->database->host,
'username' => $config->database->username,
'password' => $config->database->password,
'dbname' => $config->database->name,
'schema' => $config->database->schema,
));
});
This doesn't work!!!
$operators = new Operator;
$operator = $operators->findFirstByEmail($credentials['email']);
This works!!!
$operators = new Operator;
$app->modelsManager->setModelSchema($operators, 'myschema');
$operator = $operators->findFirstByEmail($credentials['email']);
If I don't set the schema manually then the model object can't find the tables:
Table "operators" doesn't exist on database when dumping meta-data for Operators.
I think the script is always reading the public schema instead of the one I set up.
Thanks.