zend-db icon indicating copy to clipboard operation
zend-db copied to clipboard

SQLite error on UNION

Open robob4him opened this issue 9 years ago • 1 comments

SQLite does not appreciate parentheses in UNION:

(SELECT "4" AS "column1") UNION (SELECT "5" AS "column1")
$select = (new Combine())
    ->union(
        [
            (new Select())->columns(['column1' => 4]),
            (new Select())->columns(['column1' => 5])
        ]
    );

$sql  = (new Sql(new Adapter(new PdoDriver(new Connection(new PDO('sqlite::memory:'))))));
$stmt = $sql->prepareStatementForSqlObject($select);
$result = $stmt->execute();
var_dump(iterator_to_array($result));

Zend\Db\Adapter\Exception\RuntimeException: near "(": syntax error

or explicitly on the PHP PDO instance:

PDOException: SQLSTATE[HY000]: General error: 1 near "(": syntax error

StackOverflow question reference: http://stackoverflow.com/questions/4653124

robob4him avatar Jan 27 '16 17:01 robob4him

This repository has been closed and moved to laminas/laminas-db; a new issue has been opened at https://github.com/laminas/laminas-db/issues/134.

michalbundyra avatar Jan 16 '20 19:01 michalbundyra