Igor
Igor

Reputation: 41

PDOException Zf2 with Postgresql

Hi I have a problem with Zend Framework 2.

File:
/home/marketplace/htdocs/vendor/zendframework/zendframework/library/Zend/Db/Adapter/Driver/Pdo/Statement.php:240
Message:
SQLSTATE[42P01]: Undefined table: 7 ERROR:  relation "users" does not exist
LINE 1: ...ELECT COUNT(1) AS "c" FROM (SELECT "users".* FROM "users") A...
                                                         ^

In my model I have

public function fetchAll($paginated=false)
{
    if($paginated) {
        $select = new Select('users');
        $select->order('id DESC');
        $resultSetPrototype = new ResultSet();
        $resultSetPrototype->setArrayObjectPrototype(new User());
        $paginatorAdapter = new DbSelect(
            $select,
            $this->tableGateway->getAdapter(),
            $resultSetPrototype
        );
        $paginator = new Paginator($paginatorAdapter);
        return $paginator;
    }
    $resultSet = $this->tableGateway->select(function(Select $select){
        $select->limit('30')->order('id DESC');
    });
    return $resultSet;
}

What is strange is that in locale server everything is working... Any suggestion where to find the problem? Thanks

UPDATE:

If I do the same query directly,

$sql = 'SELECT COUNT(1) AS "c" FROM (SELECT "users".* FROM "users") AS "original_select"';
$resultSet = $this->tableGateway->getAdapter()->query($sql);
return $resultSet; 

everything is ok.

Upvotes: 0

Views: 570

Answers (1)

Igor
Igor

Reputation: 41

I found the problem.

The search-path of Postgresql was setted to another Schema and not to main schema "public"

Thanks to Richard!

Upvotes: 1

Related Questions