This repository was archived by the owner on Jan 29, 2020. It is now read-only.
This repository was archived by the owner on Jan 29, 2020. It is now read-only.
Regression version 2.9.3: Using limit in subselects with PDO causes bindParameters to fail #355
Closed
Description
- I was not able to find an open or closed issue matching what I'm seeing.
- This is not a question. (Questions should be asked on slack (Signup for Slack here) or our forums.)
Sub queries with limit seems not to work like it is supposed to anymore in version 2.9.3 in combination with PDO. Likely the regression has been introduced in the following PR.
Code to reproduce the issue
$queryBuilder = \Zend\Db\Sql\Sql();
$update = $queryBuilder->update('table1');
$update->set([ 'start_date' => 'now()']);
$select = $queryBuilder
->select('table1')
->columns(['id'])
->where([
'start_date' => null,
'completed_date' => null,
])
->limit(25);
$update->where(new In('id', $select));
$statement = $queryBuilder->prepareStatementForSqlObject($update);
$statement->execute();
Expected results
The query should work as expected like in version 2.9.2
Actual results
The following query and parameters are generated:
UPDATE "table1"
SET "start_date" = :c_0
WHERE "id" IN (
SELECT "table1"."id" AS "id"
FROM "table1"
WHERE "start_date" IS NULL
AND "completed_date" IS NULL
LIMIT :limit
)
Parameters
array(2) {
["c_0"]=> string(5) "now()"
["subselect1limit"]=> int(25)
}
An exception occurs:
exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: :subselect1limit' in vendor/zendframework/zend-db/src/Adapter/Driver/Pdo/Statement.php:298
Stack trace:
#0 vendor/zendframework/zend-db/src/Adapter/Driver/Pdo/Statement.php(298): PDOStatement->bindParam(':subselect1limi...', 25, 1)
#1 vendor/zendframework/zend-db/src/Adapter/Driver/Pdo/Statement.php(232): Zend\Db\Adapter\Driver\Pdo\Statement->bindParametersFromContainer()
<snip>