PEAR is archived and read-only

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

Home » Database » DB » Bug #91

OCI8 Prepare() does not allow '!' as placeholder

Details

Submitted2003-10-13 05:30 UTC
Fromcjbj at hotmail dot com
Assigneddanielc
StatusClosed
PackageDB
PHP Version4.3.3
OSWindows 2000
Roadmaps(Not assigned)

Comments

[2003-10-13 05:30 UTC] cjbj at hotmail dot com

Description:
------------
The PEAR DB documentation for Execute [see
http://pear.php.net/manual/en/package.database.db.intro-execute.php]
says three placeholders are allowed: question mark,
exclamation point and ampersand. The common.php
implementation of Prepare() does support all three. However
the oci8.php implementation only recognizes question marks
and ampersands. This potentially impacts script migration
to the oci8 driver.

If I read the code correctly, the fix is to make oci8.php's
Prepare() recognize exclamation points like common.php's.

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

(which is pre-bug 53: http://pear.php.net/bugs/bug.php?id=53)

Potential patch:

*** oci8.php.orig Tue Sep 02 15:21:20 2003
--- oci8.php Mon Oct 13 14:37:48 2003
***************
*** 332,338 ****
*/
function prepare($query)
{
! $tokens = split('[\&\?]', $query);
$token = 0;
$types = array();
$qlen = strlen($query);
--- 332,338 ----
*/
function prepare($query)
{
! $tokens = split("[\&\?\!]", $query);
$token = 0;
$types = array();
$qlen = strlen($query);
***************
*** 343,348 ****
--- 343,351 ----
break;
case '&':
$types[$token++] = DB_PARAM_OPAQUE;
+ break;
+ case '!':
+ $types[$token++] = DB_PARAM_MISC;
break;
}
}

This makes the exclamation and ampersands have the same
behavior.

Reproduce code:
---------------
In SQL*Plus execute:

connect scott/tiger@mydb
CREATE TABLE MYTAB (C1 NUMBER)

Then run this PHP script:

<?php

require_once('DB.php');

echo "<p>Connecting . . . </p>";
$db = DB::connect("oci8://scott:tiger@MYDB");

if (DB::iserror($db))
die($db->getDebugInfo());

// Note: an exclamation point is used as the place holder
$stid = $db->prepare("INSERT INTO MYTAB (C1) VALUES (!)");
if (DB::isError($stid)) {
echo "Prepare failed:\n";
die($stid->getDebugInfo());
}

$bn = 8;

$res = $db->execute($stid, array($bn));
if (DB::isError($res)) {
echo "Execute failed:\n";
die($res->getDebugInfo());
}

echo "Insert complete.";
?>

Expected result:
----------------
After applying the patch the screen output is:

Connecting . . .
Insert complete.

Querying the table "MYTAB" from SQL*Plus shows one row with
value '8'.

Actual result:
--------------
Without the patch, no row is inserted. The screen output
is:

Connecting . . .
Execute failed: INSERT INTO MYTAB (C1) VALUES (!)