#23554 [NEW]: PEAR::DB incorrectly parses prepared statement

From: Date: Thu, 08 May 2003 23:33:46 +0000
Subject: #23554 [NEW]: PEAR::DB incorrectly parses prepared statement
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-16061@lists.php.net to get a copy of this message
From: jmikola at arsjerm dot net Operating system: Redhat Linux PHP version: 4.3.1 PHP Bug Type: PEAR related Bug description: PEAR::DB incorrectly parses prepared statement I'm using the PEAR::DB library distributed with the 4.3.1 PHP release. In the following bug, I noticed that PEAR is tossing a DB_ERROR_NEED_MORE_DATA during the parsing of the a prepared statement through a getOne() method call. Starting from the bottom, my method constructs a 2 element param array for the prepared statement (which expects two arguments), which I then pass to getOne(). I check up on the DB CVS sources for the error trigger point, and it's during token number verification prior to filling in the prepared statement: pear/DB/DB/common.php:executeEmulateQuery(). Currently, to get around this error, I've changed this query to not use a prepared statement, opting to hard-code: getOne('SELECT level & \''.$level.'\' FROM auth WHERE id=\''.$id.'\'') ..in its place (which works as expected). I've not experienced such an error in any other use of the PEAR::DB library. My script is operating on a mySQL database, and the in the 'auth' table show in my example, level is a SMALLINT and id is an INT field. PHP is version 4.3.1 running on Apache 2-current, with mySQL support compiled in. The PHP debug backtrace is as follows: /usr/local/lib/php/PEAR.php:730 trigger_error('DB Error: insufficient data supplied','256') /usr/local/lib/php/DB.php:604 pear_error('DB Error: insufficient data supplied','-20','4','256','SELECT ? & level FROM auth WHERE id=?') /usr/local/lib/php/PEAR.php:508 db_error('-20','4','256','SELECT ? & level FROM auth WHERE id=?') usr/local/lib/php/DB/common.php:296 raiseerror('','-20','','','SELECT ? & level FROM auth WHERE id=?','DB_Error','1') /usr/local/lib/php/DB/common.php:603 raiseerror('-20') /usr/local/lib/php/DB/common.php:555 executeemulatequery('1','Array') /usr/local/lib/php/DB/common.php:794 execute('1','Array') /home/website/file.php:634 getone('SELECT ? & level FROM auth WHERE id=?','Array') /home/website/file.php:89 _dbselectaccess('2','1') A script to reproduce the error is as follows: function _dbSelectAccess ($id, $level=0) { $params = array($level, $id); // $id and $level are numeric and need no escaping return $this->db->getOne('SELECT ? & level FROM auth WHERE id=?', $params); } -- Edit bug report at http://bugs.php.net/?id=23554&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=23554&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=23554&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=23554&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=23554&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=23554&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=23554&r=support Expected behavior: http://bugs.php.net/fix.php?id=23554&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=23554&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=23554&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=23554&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23554&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=23554&r=dst IIS Stability: http://bugs.php.net/fix.php?id=23554&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=23554&r=gnused

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