ID:               33707
 Updated by:       [EMAIL PROTECTED]
 Reported By:      mangst at inventec dot ch
 Status:           Assigned
 Bug Type:         PDO related
 Operating System: Windows 2000
 PHP Version:      5CVS-2005-07-14 (dev)
 Assigned To:      wez
 New Comment:

Ah, I misread the report. PDO::query() should report an error here of
course.


Previous Comments:
------------------------------------------------------------------------

[2005-07-15 08:20:07] [EMAIL PROTECTED]

>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. 

------------------------------------------------------------------------

[2005-07-14 23:58:04] [EMAIL PROTECTED]

I don't view this as a bug.  We report errors when the driver tells us
there are errors; PDO isn't doing anything wrong, per se.

I also don't see how copying the errors up from the statement to the
dbh when execute() is called will help either.


------------------------------------------------------------------------

[2005-07-14 23:37:35] [EMAIL PROTECTED]

That happens because Oracle's OCIStmtPrepare() doesn't validate the
query, it just allocates/prepares stmt handle for execution. Then PDO
happily executes this statement and all errors go to the stmt handle
(which is destroyed right after that).
Wez, from what I can see, with OCI we should always copy einfo struct
from the stmt handle to the dbh handle if stmt's execution failed.
Thoughts?

------------------------------------------------------------------------

[2005-07-14 22:07:02] 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" }


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=33707&edit=1

Reply via email to