php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58791 PDO-OCI does not throw exception with malformed sql
Submitted: 2009-08-04 11:30 UTC Modified: 2013-02-18 00:35 UTC
From: gonzalo123 at gmail dot com Assigned:
Status: No Feedback Package: PDO_OCI (PECL)
PHP Version: 5.2.10 OS: Linux 32(Suse)
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gonzalo123 at gmail dot com
New email:
PHP Version: OS:

 

 [2009-08-04 11:30 UTC] gonzalo123 at gmail dot com
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)
)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-06 06:39 UTC] bjori@php.net
(Fixed package name).

Are you using the PECL driver? Please try to the distributed with PHP.

If you are experiencing this issue in the PHP distributed PDO_OCI, please refile this bug report against PHP at http://bugs.php.net/report.php
 [2013-02-18 00:35 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 02:01:28 2024 UTC