Issues

ZF2-405: PostgreSQL driver add quotes to the sentences and postgres can't resolve them

Issue Type: Bug Created: 2012-07-17T16:40:44.000+0000 Last Updated: 2012-08-15T20:46:52.000+0000 Status: Resolved Fix version(s): Reporter: Rodolfo Bibolotti (rockdolfolk) Assignee: Ralph Schindler (ralph) Tags: - Zend\Db

  • postgres,
  • zend-db

Related issues: Attachments: - Album.php

Description

Using ZF2b5

I have problems working with postgres with Zend\Db it adds quotes to the sentences and postgres can't execute them.

This is the error:

D:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Db\Adapter\Driver\Pdo\Statement.php:214

SQLSTATE[42P01]: Undefined table: 7 ERROR: no existe la relación «zf2tutorial.album» LINE 1: SELECT "zf2tutorial.album".* FROM "zf2tutorial.album" ^

I executed the same sentence in pgsql and throws that same error. Then I removed the quotes and it works fine.

Comments

Posted by Ralph Schindler (ralph) on 2012-07-17T16:44:28.000+0000

What is the full reproduction of this issue? What method are you calling?

Posted by Rodolfo Bibolotti (rockdolfolk) on 2012-07-18T04:32:33.000+0000

Hi,

This is the message in the browser:


An error occurred An error occurred during execution; please try again later. Additional information: Zend\Db\Adapter\Exception\InvalidQueryException File: C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Db\Adapter\Driver\Pdo\Statement.php:216 Message: Statement could not be executed Stack trace:

0 C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Db\TableGateway\AbstractTableGateway.php(235): Zend\Db\Adapter\Driver\Pdo\Statement->execute()

1 C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Db\TableGateway\AbstractTableGateway.php(210): Zend\Db\TableGateway\AbstractTableGateway->executeSelect(Object(Zend\Db\Sql\Select))

2 C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Db\TableGateway\AbstractTableGateway.php(197): Zend\Db\TableGateway\AbstractTableGateway->selectWith(Object(Zend\Db\Sql\Select))

3 C:\Sistemas\zf\zf2\zf2-tutorial\module\Album\src\Album\Model\AlbumTable.php(24): Zend\Db\TableGateway\AbstractTableGateway->select()

4 C:\Sistemas\zf\zf2\zf2-tutorial\module\Album\src\Album\Controller\AlbumController.php(17): Album\Model\AlbumTable->fetchAll()

5 C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractActionController.php(150): Album\Controller\AlbumController->indexAction()

6 [internal function]: Zend\Mvc\Controller\AbstractActionController->execute(Object(Zend\Mvc\MvcEvent))

7 C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(465): call_user_func(Array, Object(Zend\Mvc\MvcEvent))

8 C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))

9 C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractActionController.php(117): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))

10 C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Mvc\DispatchListener.php(151): Zend\Mvc\Controller\AbstractActionController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))

11 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))

12 C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(465): call_user_func(Array, Object(Zend\Mvc\MvcEvent))

13 C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))

14 C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Mvc\Application.php(317): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))

15 C:\Sistemas\zf\zf2\zf2-tutorial\public\index.php(12): Zend\Mvc\Application->run()

16 {main}

Previous exceptions: PDOException File: C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Db\Adapter\Driver\Pdo\Statement.php:214 Message: SQLSTATE[42P01]: Undefined table: 7 ERROR: no existe la relación «zf2tutorial.album» LINE 1: SELECT "zf2tutorial.album".* FROM "zf2tutorial.album" ^ Stack trace:

0 C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Db\Adapter\Driver\Pdo\Statement.php(214): PDOStatement->execute()

1 C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Db\TableGateway\AbstractTableGateway.php(235): Zend\Db\Adapter\Driver\Pdo\Statement->execute()

2 C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Db\TableGateway\AbstractTableGateway.php(210): Zend\Db\TableGateway\AbstractTableGateway->executeSelect(Object(Zend\Db\Sql\Select))

3 C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Db\TableGateway\AbstractTableGateway.php(197): Zend\Db\TableGateway\AbstractTableGateway->selectWith(Object(Zend\Db\Sql\Select))

4 C:\Sistemas\zf\zf2\zf2-tutorial\module\Album\src\Album\Model\AlbumTable.php(24): Zend\Db\TableGateway\AbstractTableGateway->select()

5 C:\Sistemas\zf\zf2\zf2-tutorial\module\Album\src\Album\Controller\AlbumController.php(17): Album\Model\AlbumTable->fetchAll()

6 C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractActionController.php(150): Album\Controller\AlbumController->indexAction()

7 [internal function]: Zend\Mvc\Controller\AbstractActionController->execute(Object(Zend\Mvc\MvcEvent))

8 C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(465): call_user_func(Array, Object(Zend\Mvc\MvcEvent))

9 C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))

10 C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractActionController.php(117): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))

11 C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Mvc\DispatchListener.php(151): Zend\Mvc\Controller\AbstractActionController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))

12 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))

13 C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(465): call_user_func(Array, Object(Zend\Mvc\MvcEvent))

14 C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))

15 C:\Sistemas\zf\zf2\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Mvc\Application.php(317): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))

16 C:\Sistemas\zf\zf2\zf2-tutorial\public\index.php(12): Zend\Mvc\Application->run()

17 {main}


This is the error:

SQLSTATE[42P01]: Undefined table: 7 ERROR: no existe la relación «zf2tutorial.album» LINE 1: SELECT "zf2tutorial.album".* FROM "zf2tutorial.album" ^

This is the connection in zf2-tutorial\config\autoload:

array( 'driver' => 'Pdo\_Pgsql', 'database' => 'pruebas', 'username' => 'rusuario', 'password' => 'rusuario', 'hostname' => 'windows-db' ), 'service\_manager' => array( 'factories' => array( 'Zend\\Db\\Adapter\\Adapter' => 'Zend\\Db\\Adapter\\AdapterServiceFactory', ), ), ); Thanks. Posted by Ralph Schindler (ralph) on 2012-08-14T15:48:04.000+0000 I realize you are using Akrabat's ZF2 Tutorial, but what exactly is the API call to Zend\\Db\\Sql that is causing this error? Posted by Rodolfo Bibolotti (rockdolfolk) on 2012-08-15T03:53:44.000+0000 Yes, is the akrabat's ZF2 tutorial but using postgres. The sentence is return new ViewModel(array( 'albums' => $this->getAlbumTable()->fetchAll(), in the AlbumController. I'm attaching the AlbumController class, the Album class and the AlbumTable class Posted by Rodolfo Bibolotti (rockdolfolk) on 2012-08-15T03:56:59.000+0000 AlbumController is in C:\\Sistemas\\zf\\zf2\\zf2-tutorial\\module\\Album\\src\\Album\\Controller Album and AlbumTable are in C:\\Sistemas\\zf\\zf2\\zf2-tutorial\\module\\Album\\src\\Album\\Model Posted by Rodolfo Bibolotti (rockdolfolk) on 2012-08-15T04:05:01.000+0000 this is the whole project. It is not complete because in the tutorial I can't continue from this test: this is the virtual host: ServerName zf2-tutorial DocumentRoot c:/sistemas/zf/zf2/zf2-tutorial/public SetEnv APPLICATION\_ENV "development" DirectoryIndex index.php AllowOverride All Order allow,deny Allow from all Thanks. Posted by Ralph Schindler (ralph) on 2012-08-15T16:28:53.000+0000 I've downloaded Akrabats tutorial and I can confirm it works on Postgresql. If you find it doesn't work still, please file issues with his project here: -ralph Posted by Rodolfo Bibolotti (rockdolfolk) on 2012-08-15T20:46:52.000+0000 thanks Ralph. I dowloaded all the tutorial and I works well (after some intents) when I don't use a schema. Is there a way to specify a schema in ZF2?

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts