#72 [Opn->Csd]: OCI8 Execute always requires placeholders

From: Date: Tue, 07 Oct 2003 13:56:46 +0000
Subject: #72 [Opn->Csd]: OCI8 Execute always requires placeholders
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-22447@lists.php.net to get a copy of this message
ID: 72 Updated by: cox@php.net Reported By: cjbj at hotmail dot com -Status: Open +Status: Closed Bug Type: DB Operating System: Windows 2000 PHP Version: 4.3.3 Assigned To: cox New Comment: This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better. Previous Comments: ------------------------------------------------------------------------ [2003-10-07 09:47:25] cjbj at hotmail dot com Your new fix also resolves the problem. ------------------------------------------------------------------------ [2003-10-07 08:11:04] cox@php.net Could you please test if this patch solves the problem? - function &execute($stmt, $data = false) + function &execute($stmt, $data = array()) Thanks ------------------------------------------------------------------------ [2003-10-07 00:25:50] cjbj at hotmail dot com Description: ------------ There is a problem in PEAR DB's OCI8 "Execute" function. If the statement "prepared" does not have any placeholders (aka bind variables), "execute" does not allow an empty second argument. Patch: The affected file has timestamp: // $Id: oci8.php,v 1.10 2003/06/11 16:42:44 cox Exp $ diff "c:/php/PEAR/DB/oci8.php.orig" "c:/php/PEAR/DB/oci8.php" 378,380c378,384 < $types=&$this->prepare_types[$stmt]; < if (($size = sizeof($types)) != sizeof($data)) { < return $this->raiseError(DB_ERROR_MISMATCH); --- > if (!$data) > $size = 0; > else { > $types = &$this->prepare_types[$stmt]; > if (($size = sizeof($types)) != sizeof($data)) { > return $this->raiseError(DB_ERROR_MISMATCH); > } Reproduce code: --------------- <?php // connect require_once('DB.php'); $db = DB::connect("oci8://scott:tiger@mydb"); if (DB::iserror($db)) { die($db->getMessage()); } echo "Connected\n"; // issue the query $sql = "create table test1 (mycol varchar2(20))"; $q = $db->prepare($sql); if (DB::iserror($q)) { die($q->getMessage()); } $r = $db->execute($q); if (DB::iserror($r)) { die($r->getMessage()); } echo "Table created\n"; // issue the query $sql = "insert into test1 values ('ff')"; $q = $db->prepare($sql); if (DB::iserror($q)) { die($q->getMessage()); } $r = $db->execute($q); if (DB::iserror($r)) { die($r->getMessage()); } echo "Row inserted\n"; ?> Expected result: ---------------- Connected Table created Row inserted (And the table is created with one row inserted.) Actual result: -------------- Connected DB Error: mismatch (And the table is not created) ------------------------------------------------------------------------ -- Edit this bug report at http://pear.php.net/bugs/bug.php?id=72&edit=1

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