PEAR is archived and read-only

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

Home » Database » DB » Bug #72

OCI8 Execute always requires placeholders

Details

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

Comments

[2003-10-07 04:25 UTC] 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)

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

Your new fix also resolves the problem.