|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-05-12 09:29 UTC] lsmith@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 16:00:01 2025 UTC |
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); }