zend-db
zend-db copied to clipboard
Functions as table part in Zend\Db\Sql\Select not quoted correctly when using pdo_pgsql driver
I'm trying to use a function as a table in Zend\Db\Sql\Select and it appears to be quoting incorrectly. The entire function including parens is wrapped in quotes and I get an error saying the table doesnt exist.
<?php
require_once 'vendor/autoload.php';
$config = [
'driver' => 'pdo_pgsql',
'host' => 'postgresvm.dev',
'username' => 'user',
'password' => 'pass',
'dbname' => 'mydb',
'port' => 5432
];
$dbAdapter = new \Zend\Db\Adapter\Adapter($config);
$sqlAdapter = new \Zend\Db\Sql\Sql($dbAdapter);
$select = new \Zend\Db\Sql\Select();
$select->from("my_schema.ufn_user_client(2, 3)");
$results = $dbAdapter->query(
$sqlAdapter->buildSqlString($select),
\Zend\Db\Adapter\Adapter::QUERY_MODE_EXECUTE
)->toArray();
var_dump($results);
PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "my_schema.ufn_user_client(2, 3)" does not exist. I've tried wrapping it in a Zend\Db\Sql\Expression but it requires the table name to be a string.