Home » Database » DB » Bug #72
OCI8 Execute always requires placeholders
Details
| Submitted | 2003-10-07 04:25 UTC |
|---|---|
| From | cjbj at hotmail dot com |
| Assigned | cox |
| Status | Closed |
| Package | DB |
| PHP Version | 4.3.3 |
| OS | Windows 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.