PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB » Bug #73

[PATCH] OCI8 Prepare() does not raise SQL parse error

Details

Submitted2003-10-07 07:23 UTC
Fromcjbj at hotmail dot com
Assignedcox
StatusClosed
PackageDB
PHP Version4.3.3
OSWindows 2000
Roadmaps(Not assigned)

Comments

[2003-10-07 07:23 UTC] cjbj at hotmail dot com

Description:
------------
SQL parse errors in PEAR DB's OCI8 "Prepare" function are not
raised. A subsequent call to DB::iserror($db) returns false as if the
statement was successful.

A patch to prepare() fixed the problem for me.

The affected file has timestamp:
// $Id: oci8.php,v 1.10 2003/06/11 16:42:44 cox Exp $

*** oci8.php.orig Tue Sep 02 15:21:20 2003
--- oci8.php Tue Oct 07 17:10:44 2003
***************
*** 354,360 ****
$newquery .= $tokens[$i];
$this->last_query = $query;
$newquery = $this->modifyQuery($newquery);
! $stmt = @OCIParse($this->connection, $newquery);
$this->prepare_types[$stmt] = $types;
$this->manip_query[(int)$stmt] = DB::isManip($query);
return $stmt;
--- 354,361 ----
$newquery .= $tokens[$i];
$this->last_query = $query;
$newquery = $this->modifyQuery($newquery);
! if (!$stmt = @OCIParse($this->connection, $newquery))
! return $this->oci8RaiseError();
$this->prepare_types[$stmt] = $types;
$this->manip_query[(int)$stmt] = DB::isManip($query);
return $stmt;

Reproduce code:
---------------
<?php

require_once('DB.php');

$db = DB::connect("oci8://scott:tiger@MYDB");
if (DB::iserror($db)) {
echo $db->getDebugInfo();
die();
}

$s = $db->prepare("select 'x from dual");
if (DB::isError($s)) {
echo $s->getDebugInfo();
}
else {
echo "No error\n";
}

?>

Expected result:
----------------
After patching oci8.php, the error below should be displayed:

select 'x from dual [nativecode=ORA-01756: quoted string not properly terminated ]

Actual result:
--------------
Currently the text "No error" is displayed.