Hi,
First, apologies for my bad english.
Second, I have a problem with PostgreSQL in a model connection with my database in PostgreSQL.
This is the error: Table "noticia" doesn't exist on database when dumping meta-data for Spa\Common\Models\Noticia
My config file:
'database' => array(
'development' => array(
'master' => array(
'host' => 'localhost',
'username' => 'user',
'password' => 'XXX',
'dbname' => 'spav4',
'port' => '5432',
'schema' => 'public',
),
'slave' => array(
'host' => 'localhost',
'username' => 'user',
'password' => 'XXX',
'dbname' => 'spav4',
'port' => '5432',
'schema' => 'public',
)
)
);
And my service.php
$di->setShared('spaDbMaster', function () use ($config) {
$enviroment = $config->database->{APPLICATION_ENV}->master;
return new DbAdapter(array(
'host' => $enviroment->host,
'port' => $enviroment->port,
'username' => $enviroment->username,
'password' => $enviroment->password,
'dbname' => $enviroment->dbname,
'schema' => $enviroment->schema
));
});
$di->setShared('spaDbSlave', function () use ($config) {
$enviroment = $config->database->{APPLICATION_ENV}->slave;
return new DbAdapter(array(
'host' => $enviroment->host,
'port' => $enviroment->port,
'username' => $enviroment->username,
'password' => $enviroment->password,
'dbname' => $enviroment->dbname,
'schema' => $enviroment->schema
));
});
And finally my class
namespace Spa\Common\Models;
use \Phalcon\Mvc\Model;
class Noticia extends Model
{
.....
/**
* Método de inicialización del modelo
*/
public function initialize()
{
$this->setReadConnectionService('spaDbSlave');
$this->setWriteConnectionService('spaDbMaster');
$this->belongsTo('fk_id_servidor', 'Spa\Common\Models\Servidor', 'id_servidor', array(
'alias' => 'Servidor',
'foreignKey' => array(
'message' => 'No existe el servidor seleccionado'
)
));
$this->belongsTo('fk_id_usuario', 'Spa\Common\Models\Usuario', 'id_usuario', array(
'alias' => 'Usuario',
'foreignKey' => array(
'message' => 'No existe el usuario seleccionado'
)
));
$this->setSource('noticia');
}
....
}
And my IndexController
<?php
namespace Spa\Common\Controllers;
class IndexController extends ControllerBase
{
public function indexAction()
{
$objNoticia = new \Spa\Common\Models\Noticia();
$noticias = $objNoticia->find(); // HERE LAUNCH ERROR
}
}
I test commenting the belongsTo lines and didn't work.
But my table "version" which is in the same database and the same schema works fine (reading at least, i don't probe the writting process)
Please can you help me with this problem.
Thanks