You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.
So I've been hitting my head on the wall for the entire day on this and I just managed to figure it out.
Although in theory zend-db is properly handling boolean values in the Statement:: bindParametersFromContainer() it appears that there is a bug lying in PHP which is still there in 7.1 and 7.2 (https://bugs.php.net/bug.php?id=38546).
Passing PDO::PARAM_BOOL in the bindParam causes the PDOStatement::execute() to silentlyreturn false and not throw any exception, even though PDO::ATTR_ERRMODE is set to PDO::ERRMODE_EXCEPTION
The reason I'm opening this is to bring it to your attention and perhaps discuss if booleans should be treated as integers until a fix is available
Code to reproduce the issue
$sql = newSql($this->getDbAdapter());
$insert = $sql->insert()
->into('Table')
->values([ 'field' => true ]);
try {
$insertStatement = $sql->prepareStatementForSqlObject($insert);
$result = $insertStatement->execute();
} catch( \Exception$e ) {
// will never get here
}
// this is falsereturn ( $result && $result->getAffectedRows() > 0 );
Expected results
The statement should get prepared in the mysql and then get executed. However that is not the case. Looking into mysql's general_log_file one can see the statement being prepared but never executed.
Actual results
PDOStatement::execute() returns false and no exception was thrown thus the only way to detect that the query failed is via the getAffectedRows() but there is absolutely no indication on what went wrong.
The text was updated successfully, but these errors were encountered:
It's been a while but I believe this happened on PHP 7.2.6, mySQL 5.7.22 and zend-db 2.9.3. I will remove my workaround and see if I can still reproduce it
So I've been hitting my head on the wall for the entire day on this and I just managed to figure it out.
Although in theory zend-db is properly handling boolean values in the
Statement:: bindParametersFromContainer()
it appears that there is a bug lying in PHP which is still there in 7.1 and 7.2 (https://bugs.php.net/bug.php?id=38546).Passing
PDO::PARAM_BOOL
in thebindParam
causes thePDOStatement::execute()
to silentlyreturn false
and not throw any exception, even thoughPDO::ATTR_ERRMODE
is set toPDO::ERRMODE_EXCEPTION
The reason I'm opening this is to bring it to your attention and perhaps discuss if booleans should be treated as integers until a fix is available
Code to reproduce the issue
Expected results
The statement should get prepared in the mysql and then get executed. However that is not the case. Looking into mysql's general_log_file one can see the statement being prepared but never executed.
Actual results
PDOStatement::execute()
returns false and no exception was thrown thus the only way to detect that the query failed is via thegetAffectedRows()
but there is absolutely no indication on what went wrong.The text was updated successfully, but these errors were encountered: