|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-03-01 19:59 UTC] terry at bitsoup dot com
Description:
------------
A fetch against a statment that returns an empty resultset doesn't set any PDO error information, nor does it raise an exception.
Testing against MySQL 5.0.18
Reproduce code:
---------------
Database connection is successful, and mode is set to throw exceptions:
try
{
$sth = $dbh->prepare("SELECT * from any_table where 1=2");
$sth->execute();
$row = $sth->fetch();
echo "ERROR=" . $sth->errorCode();
}
catch (PDOException $e)
{
dbg("DB Error!: " . $e->getMessage());
die();
}
Expected result:
----------------
Either
ERROR=20
when not using exceptions, or an exception.
Actual result:
--------------
ERROR=00
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 23:00:01 2025 UTC |
That's because you are currently discarding the error in oci8. You have it on the TODO list to handle the fetch case properly. if ((statement->error == OCI_NO_DATA) || (nrows == 0)) { if (statement->last_query == 0) { /* reset define-list for refcursors */ if (statement->columns) { zend_hash_destroy(statement->columns); efree(statement->columns); statement->columns = 0; statement->ncolumns = 0; } statement->executed = 0; } statement->error = 0; /* OCI_NO_DATA is NO error for us!!! */ statement->has_data = 0; return 0; }