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

PostgreSQL problem with tables

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

Maybe can help in the solution.

I have phalcon 1.2.6 and I get from GIT My postgreSQL is the version 9.1.8 My PHP version is 5.5.9-1 My OS is Linux Debian wheezy kernel 3.2.39-2 x86_64

what's happening with this? Still wait for somebody helpme with this, and i search and search in google, but the information is useless. Please some can help me with this problem, i need solve this quick and i start to see another framework, but i don't want change phalcon for another (i don't have time for this).

Thank you