[DC-841] Doctrine_Connection_Mssql::replaceBoundParamsWithInlineValuesInQuery regex failing to replace all '?' instances [patch+] Created: 25/Aug/10 Updated: 05/Mar/11
|Reporter:||Daniel Cousineau||Assignee:||Jonathan H. Wage|
PHP 5.2.11, Apache, Microsoft SQL Server 2005
When executing queries with WHERE statements using multiple instances of the "<>" operator (as well as other non =,( symbols inbetween definitions), the method Doctrine_Connection_Mssql::replaceBoundParamsWithInlineValuesInQuery fails to identify all ? replacements.
In the following piece of code I have a query (trimmed for readability and renamed for privacy) that fails to have all "?" symbols replaced as well as the relevant code from the method mentioned above (minus the return statement) doing a simple demonstration:
Running this code produces:
Unfortunately the regex will not identify all the ? instances properly in the query when run like preg_match_all(), which was my first idea to fix (pre-identify all ? instances, then go through and replace them).
The only 3 potential solutions I can think of are:
1. Pre-identify all ?'s and note their position in the string, to do this using a much looser regex, then replace all the ?'s found
|Comment by Daniel Cousineau [ 25/Aug/10 ]|
I am probably way over thinking a solutions, however since I have to run home and don't have time to flesh this out further at the moment, my initial idea is something like this:
Which is what we would expect, as well as it doesn't take into account for newly inserted data containing '?' symbols.
But again this is just playing around with potential solutions.
|Comment by Enrico Stahn [ 27/Aug/10 ]|
The patch and a Test Case can be found at: http://github.com/estahn/doctrine1/compare/master...DC-841
|Comment by Enrico Stahn [ 02/Sep/10 ]|
I made a mistake with github, the updated branch can be found at
|Comment by Lionel ROTA [ 05/Mar/11 ]|
Doesn't work with :
The question mark is captured...
This code seems working :