#23554 [Opn->Asn]: PEAR::DB incorrectly parses prepared statement

From: Date: Sat, 10 May 2003 21:01:40 +0000
Subject: #23554 [Opn->Asn]: PEAR::DB incorrectly parses prepared statement
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-16121@lists.php.net to get a copy of this message
ID: 23554 Updated by: arnaud@php.net Reported By: jmikola at arsjerm dot net -Status: Open +Status: Assigned Bug Type: PEAR related Operating System: Redhat Linux PHP Version: 4.3.1 -Assigned To: +Assigned To: lsmith Previous Comments: ------------------------------------------------------------------------ [2003-05-08 18:33:46] jmikola at arsjerm dot net 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 this bug report at http://bugs.php.net/?id=23554&edit=1

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