Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.12.1

Bug #780 DB/common.php -> DB mismatch (DB 1.6.0RC6)
Submitted: 2004-02-17 19:23 UTC
From: jkaufman at wamnetgov dot com Assigned: danielc
Status: Bogus Package: DB
PHP Version: 4.3.4 OS: Linux - Mandrake 9.1
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 32 + 27 = ?

 
 [2004-02-17 19:23 UTC] jkaufman at wamnetgov dot com
Description: ------------ v1.24 of common.php, no problem. v1.87 of common.php gives a db mismatch error. My query is a simple one: select task_id, task_code, task_descr from task_master, task_wbs_element where task_id in (31) (works fine in dbaccess) I am using this command to execute the query: $res = $dbh->query($sql, DB_FETCHMODE_ASSOC); The new code contains this in executeEmulateQuery: if (count($this->prepare_types[$stmt]) != count($data)) { $this->last_query = $this->prepared_queries[$stmt]; return $this->raiseError(DB_ERROR_MISMATCH); } And that is where it fails. I don't understand why a simple query needs to go through prepare/execute, nor what I need to do to fix this. Reproduce code: --------------- All is shown above. Expected result: ---------------- Values from db, not 'db mismatch error'. Actual result: -------------- db_error Object ( [error_message_prefix] => [mode] => 16 [level] => 1024 [code] => -7 [message] => DB Error: mismatch [userinfo] => select task_id, task_code, task_descr, task_wbs_element from task_master where task_id in (31) [backtrace] => Array ( [0] => Array ( [file] => /usr/share/pear/DB.php [line] => 739 [function] => pear_error [class] => db_error [type] => -> [args] => Array ( [0] => DB Error: mismatch [1] => -7 [2] => 16 [3] => handle_Error [4] => select task_id, task_code, task_descr, task_wbs_element from task_master where task_id in (31) ) ) [1] => Array ( [file] => /usr/share/pear/PEAR.php [line] => 525 [function] => db_error [class] => db_error [type] => -> [args] => Array ( [0] => -7 [1] => 16 [2] => handle_Error [3] => select task_id, task_code, task_descr, task_wbs_element from task_master where task_id in (31) ) ) [2] => Array ( [file] => /usr/share/pear/DB/common.php [line] => 495 [function] => raiseerror [class] => pear [type] => :: [args] => Array ( [0] => [1] => -7 [2] => [3] => [4] => select task_id, task_code, task_descr, task_wbs_element from task_master where task_id in (31) [5] => DB_Error [6] => 1 ) ) [3] => Array ( [file] => /usr/share/pear/DB/common.php [line] => 980 [function] => raiseerror [class] => db_ifx [type] => -> [args] => Array ( [0] => -7 ) ) [4] => Array ( [file] => /usr/share/pear/DB/common.php [line] => 940 [function] => executeemulatequery [class] => db_ifx [type] => -> [args] => Array ( [0] => 0 [1] => 2 ) ) [5] => Array ( [file] => /usr/share/pear/DB/common.php [line] => 1130 [function] => execute [class] => db_ifx [type] => -> [args] => Array ( [0] => 0 [1] => 2 ) ) [6] => Array ( [file] => /var/www/html/tsg_2.20/enter_service_request3.php [line] => 74 [function] => query [class] => db_ifx [type] => -> [args] => Array ( [0] => select task_id, task_code, task_descr, task_wbs_element from task_master where task_id in (31) [1] => 2 ) ) ) [callback] => handle_Error )

Comments

 [2004-02-17 20:55 UTC] danielc
It's a bug in your program. Element 6 of the backtrace you posted says line 74 of enter_service_request3.php calls query() with two arguments: the query string and a value of 2. When a second argument is passed to query(), it assumes you want that do a prepare/execute procedure. Since you passed one value to the second argument, there should be one placeholder in the SQL prepare statement passed to argument one. But there are no placeholders. So, of course an error gets raised. By the way, when submitting bugs in the future, please provide complete (but short) example scripts that run on their own without us having to do any guesswork as to what you're talking about.