Skip to content

[Linux] PDO driver should not throw exception on "closeCursor()" #267

@deeky666

Description

@deeky666

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions