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

Bug #21217 autoExecute failed UPDATE if placeholders presents in WHERE
Submitted: 2017-06-02 12:13 UTC
From: enyby Assigned: ashnazg
Status: Assigned Package: DB (version 1.9.2)
PHP Version: 5.6.29 OS: ANY
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 : 20 - 5 = ?

 
 [2017-06-02 12:13 UTC] enyby (Enyby Rapidfly)
Description: ------------ If you call autoExecute() and in WHERE present any of '!?&' query simple fails. Does not matter where these symbols appear - inside string literal or in query (for example 'a != b'). This happens because inside autoExecute() where used for catch placeholders. For example you send to autoExecute() array with $data of 3 items and $where with 'a != b'. On autoPrepare() inside autoExecute() will be collected FOUR placeholders. 3 from $data and '!' inside $where as 4 placeholder. After that will be called execute() with $data array. But it have only 3 values. It cause error because parsed statement required 4 values for 4 placeholders. Solution: make replace in $where before send it to autoPrepare() inside autoExecute(): if ($where) { $where = strtr($where, array('?' => '\?', '!' => '\!', '&' => '\&',)); } Test script: --------------- $data = array('a' => 'a', 'b' => 'b', 'c' => 'c'); $ret = $db->autoExecute('table', $data, DB_AUTOQUERY_UPDATE, 'a != b'); var_dump($ret); Expected result: ---------------- DB_OK Actual result: -------------- DB_ERROR: DB_ERROR_MISMATCH raised from executeEmulateQuery()

Comments

 [2018-07-20 18:30 UTC] ashnazg (Chuck Burgess)
-Status: Open +Status: Assigned -Assigned To: +Assigned To: ashnazg
https://github.com/pear/DB/pull/3