Fix autoExecute failed UPDATE if placeholders presents in WHERE (bug #21217) #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
autoExecute failed UPDATE if placeholders presents in WHERE
See bug #21217: https://pear.php.net/bugs/bug.php?id=21217
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():
Test script:
Expected result:
DB_OK
Actual result:
DB_ERROR: DB_ERROR_MISMATCH raised from executeEmulateQuery()