Prepared query wrong number of parameter on 2.9.3
Opened this issue · 2 comments
trasher commented
- 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.)
Trying to execute a prepared query with named parameters. Works well with 2.9.2 but fails on 2.9.3.
Code to reproduce the issue
Something like:
$insert = $zdb->sql->insert(self::TABLE);
$insert->values(
array(
'name' => ':name',
'value' => ':value'
)
);
$stmt = $zdb->sql->prepareStatementForSqlObject($insert);
foreach ($values as $k => $v) {
$stmt->execute(
array(
'name' => $k,
'value' => $v
)
);
}
Expected results
Query success.
Actual results
Fails with the following exception:
==> An exception has been thrown in file tests/units/Preferences.php on line xx:
==> PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in vendor/zendframework/zend-db/src/Adapter/Driver/Pdo/Statement.php:239
==> Stack trace:
==> #0 vendor/zendframework/zend-db/src/Adapter/Driver/Pdo/Statement.php(239): PDOStatement->execute()
==> #1 lib/Preferences.php(310): Zend\Db\Adapter\Driver\Pdo\Statement->execute(Array)
[...]
Array passed to Statement::execute()
looks like:
array(
'name' => 'lang',
'value' => 'en_US'
)
Thank you.
guillomovitch commented
The problem persists with zend-db 2.10.0.
michalbundyra commented
This repository has been closed and moved to laminas/laminas-db; a new issue has been opened at laminas/laminas-db#47.