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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Fri Mar 29 15:01:28 2024 UTC