Bug #17270 [Opn->Bgs]: prepare(), execute() fail when statement combines placeholders and null values

From: Date: Wed, 24 Oct 2012 15:27:26 +0000
Subject: Bug #17270 [Opn->Bgs]: prepare(), execute() fail when statement combines placeholders and null values
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to pear-bugs+get-9219@lists.php.net to get a copy of this message
Edit report at https://pear.php.net/bugs/bug.php?id=17270&edit=1 ID: 17270 Updated by: danielc@analysisandsolutions.com Reported By: tom dot milbank at space dot utah dot edu Summary: prepare(), execute() fail when statement combines placeholders and null values -Status: Open +Status: Bogus Type: Bug Package: MDB2 Operating System: Solaris 5.10 Package Version: 2.5.0b2 PHP Version: 5.2.5 -Assigned To: +Assigned To: danielc Roadmap Versions: New Comment: -Status: Open +Status: Bogus -Assigned To: +Assigned To: danielc In SVN commit r328130, I added a testBug17270() method in tests/Standard/BugsTest.php. The test passes (I used mysql, mysqli, and pgsql) when running the against the beta release that came out yesterday (2.5.0b4). Not sure if the beta fixed the release the users are running or if there are overriding factors in the users' code or environment that are/were causing the problems. http://svn.php.net/viewvc/pear/packages/MDB2/trunk/tests/Standard/BugsTest.php?view=markup Marking this "bogus" so it doesn't show up as fixed when generating the next release. Previous Comments: ------------------------------------------------------------------------ [2011-03-13 12:08:12] alec 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'; set_include_path($path); 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. ------------------------------------------------------------------------ [2010-03-25 20:47:27] tmilbank Description: ------------ The prepare() method fails when a statement combines named placeholders and null values. The execute() method fails when a statement 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 (\N,:user_id,:remote_addr,:http_user_agent,\N,'0') "; $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: " . $dbh->getMessage()); $sth = $dbh->prepare($statement); if (PEAR::isError($sth)) throw new Exception("Couldn't prepare statement: " . $sth->getMessage()); $rc = $sth->execute($bind_values); if (PEAR::isError($rc)) throw new Exception("Couldn't execute statement: " . $rc->getMessage()); 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" ------------------------------------------------------------------------ -- Edit this bug report at https://pear.php.net/bugs/bug.php?id=17270&edit=1

« previous php.pear.bugs (#9219) next »