#91 [NEW]: OCI8 Prepare() does not allow '!' as placeholder

From: Date: Mon, 13 Oct 2003 05:30:32 +0000
Subject: #91 [NEW]: OCI8 Prepare() does not allow '!' as placeholder
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-22625@lists.php.net to get a copy of this message
From: cjbj at hotmail dot com Operating system: Windows 2000 PHP version: 4.3.3 PHP Bug Type: DB Bug description: OCI8 Prepare() does not allow '!' as placeholder 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 (!) -- Edit bug report at http://pear.php.net/bugs/bug.php?id=91&edit=1 --

« previous php.pear.dev (#22625) next »