Bug #16773 [NEW]: PDO-OCI does not throw exception with malformed sql

From: Date: Tue, 04 Aug 2009 15:30:24 +0000
Subject: Bug #16773 [NEW]: PDO-OCI does not throw exception with malformed sql
Groups: php.pear.webmaster 
Request: Send a blank email to pear-webmaster+get-6598@lists.php.net to get a copy of this message
From: gonzalo123 at gmail dot com Operating system: Linux 32(Suse) Package version: PHP version: 5.2.10 Package: Bug System Bug Type: Bug Bug description: PDO-OCI does not throw exception with malformed sql Description: ------------ PDO doesn't throw any exception (at least with Oracle) in some cases but I can see the error with $db->errorInfo(). I notice this happens when I bind some unexistent variables to the query. I know it is wrong (bind unexistent variables) but in my opinion PDO must throw an exception (because $db->errorInfo() knows the error) Reproduce code: --------------- // create table TBLDUMMY (FIELD1 VARCHAR2(2), FIELD2 VARCHAR2(2)) $db = new PDO( $dsn, // my DB dsn $user, // database username $password); // database password try { $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = "select FIELD1, FIELD2 FROM TBLDUMMY"; //$sqlOK = "select FIELD1, FIELD2 FROM TBLDUMMY WHERE FIELD1=:F1"; $stmt = $db->prepare($sql); $stmt->execute(array('F1' => '1')); $result = $stmt->fetchAll(); echo "<pre>"; print_r($db->errorInfo()); echo "</pre>"; } catch (Exception $e) { echo "Exception:" . $e->getMessage(); } Expected result: ---------------- Exception OCIBindByName: ORA-01036: número/nombre de variable no válido Actual result: -------------- Array ( [0] => HY000 [1] => 1036 [2] => OCIBindByName: ORA-01036: número/nombre de variable no válido (/usr/local/PDO_OCI-1.0/oci_statement.c:287) ) -- Edit bug report at http://pecl.php.net/bugs/bug.php?id=16773&edit=1 --

« previous php.pear.webmaster (#6598) next »