|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-07-14 22:07 UTC] mangst at inventec dot ch
Description:
------------
When a SQL statement is executed with PDO::query, PDO::errorInfo[0] always reports "00000" even when an error has occurred and PDO::query returned <false>.
Reproduce code:
---------------
<?php
try {
$db = new PDO('oci:dbname=***', '***', '***');
} catch (PDOException $e) {
exit ("Failed to obtain db handle: " . $e->getMessage());
}
$rs = $db->query('select nvarchar(8) from dual');
echo 'Statement handle: ';
var_dump($rs);
echo "<br />\r\nError info of database handle: ";
var_dump($db->errorInfo());
$db = null;
?>
Expected result:
----------------
Somthing like:
Statement handle: bool(false)
Error info of database handle: array(1) { [0]=> string(5) "42000" [1]=> "????" [2]=> string(x) "ORA-00904: "NVARCHAR": invalid identifier"}
Actual result:
--------------
Statement handle: bool(false)
Error info of database handle: array(1) { [0]=> string(5) "00000" }
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 00:00:01 2025 UTC |
>I don't view this as a bug. You can't reproduce it? I can. >We report errors when the driver tells us there are errors; > PDO isn't doing anything wrong, per se. But there was an error, it's just hidden. This code works fine: <?php $db = new PDO('oci:dbname=..', '..', '..'); $st = $db->prepare('select blah from dual'); $rs = $st->execute(); var_dump($rs); var_dump($st->errorInfo()); ?> And this doesn't (only with OCI): <?php $db = new PDO('oci:dbname=..', '..', '..'); $rs = $db->query('select blah from dual'); var_dump($rs); var_dump($db->errorInfo()); ?> This happens because with MySQL it fails on prepare stage, but OCI passes prepare and fails only while executing the statement, so the error goes to the statement handle.