ID: 36578
User updated by: terry at bitsoup dot com
Reported By: terry at bitsoup dot com
-Status: Bogus
+Status: Open
Bug Type: PDO related
Operating System: Windows XP
PHP Version: 5.1.2
New Comment:
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;
}
Previous Comments:
------------------------------------------------------------------------
[2006-03-02 17:51:03] [EMAIL PROTECTED]
$s = oci_parse($c, "select 1 from dual where 1 = 2");
oci_execute($s);
var_dump(oci_fetch($s));
=>
bool(false) and no error.
------------------------------------------------------------------------
[2006-03-02 17:25:21] terry at bitsoup dot com
The empty resultset is not the error. Calling fetch() on an empty
resultset sets the error code to a warning and/or generates an
exception in every database engine I've seen.
In Oracle, it's error ORA-1403: no data found.
It's SQL_NODATA in ODBC drivers.
I believe it's Error 2053 in MySQL. mysql_stmt_fetch() returns
MYSQL_NO_DATA, and not 0 for success.
In it's current state, fetch() returning null without raising the
exception means we'll have to add the test and throw the exception
manually on every single query.
------------------------------------------------------------------------
[2006-03-02 08:42:51] [EMAIL PROTECTED]
Empty resultset is not an error, it's a common situation.
No bug here.
------------------------------------------------------------------------
[2006-03-01 20:01:39] terry at bitsoup dot com
Sorry, error code should be 02, not 20
------------------------------------------------------------------------
[2006-03-01 19:59:35] 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
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36578&edit=1