-
Notifications
You must be signed in to change notification settings - Fork 374
Closed
Labels
Description
The PDO driver throws the following exception when trying to close a prepared statement cursor with PDOStatement::closeCursor()
if the statement has not been executed yet.
The statement must be executed before results can be retrieved.
While this is not completely wrong, the behaviour does not adhere to the PDO interface. The contract clearly states that in case of an error false
is to be returned. Exceptions not allowed.
This is especially important when trying to build database abstractions where consistent behaviour across different PDO implementation is desired. We currently have discovered that issue in our testsuite (Doctrine DBAL). While all PDO implementations we support return false
, pdo_sqlsrv
throws an exception.
$connection = new \PDO(/* connection parameters */);
$statement = $connection->prepare('SELECT foo FROM bar');
$statement->closeCursor();
Any chance we can change the driver's behaviour here?