Edit report at http://pear.php.net/bugs/bug.php?id=17270&edit=1

ID: 17270
Updated by: alec@alec.pl
Reported By: tom dot milbank at space dot utah dot edu
Summary: prepare(), execute() fail when statement combines
placeholders and null values
Status: Open
Type: Bug
Package: MDB2
Operating System: Solaris 5.10
Package Version: 2.5.0b2
PHP Version: 5.2.5
Roadmap Versions:
New Comment:

I've found the reason. This is a problem with module class loading. It
works fine when you add the directory with MDB2.php and MDB2/ into
include_path. For example:

$path = ini_get('include_path');
$path .= PATH_SEPARATOR.'./path/to/mdb2/main/file';

When you enable debug option you'll see warnings. However I think these
warnings are not relevant, because are pointing to non-existing file.

Warning: include_once(MDB2/Datatype.php): failed to open stream: No such
file or directory in ......./MDB2.php on line 330
Warning: include_once(): Failed opening 'MDB2/Datatype.php' for
inclusion (include_path='.:/usr/share/php:/usr/share/pear') in
......./MDB2.php on line 330.

I propose to fix MDB2::fileExists() to support paths relative to
MDB2.php file location or at least warn the user that including MDB2.php
file is not enough.

Previous Comments:

[2010-03-25 20:47:27] tmilbank

The prepare() method fails when a statement combines named
placeholders and null values. The execute() method fails when a
combines unnamed placeholders and null values.

Using: MDB2 2.5.0b2, MDB2_Driver_mysql 1.5.0b2, MySQL 5.0.27

Test script:
$dsn = array(*supply info*);

$statement = "INSERT INTO access_log VALUES
$bind_values = array(':user_id' => '1002',':remote_addr' =>
'XXX.XXX.XXX.XXX',':http_user_agent' => 'http user agent information');

$dbh = MDB2::connect($dsn);
if (PEAR::isError($dbh))
throw new Exception("Couldn't connect to database: " .

$sth = $dbh->prepare($statement);
if (PEAR::isError($sth))
throw new Exception("Couldn't prepare statement: " .

$rc = $sth->execute($bind_values);
if (PEAR::isError($rc))
throw new Exception("Couldn't execute statement: " .

Expected result:
I expect to have new record inserted in the access_log table. MDB2
release 2.4.1 will insert the record as expected.

Actual result:
The prepare() method returns "MDB2 Error: syntax error"


Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
postedMar 13, '11 at 11:05a
activeMar 13, '11 at 11:05a

1 user in discussion

Alec: 1 post



site design / logo © 2022 Grokbase