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

Bug #18686 bindname_format option regex changed
Submitted: 2011-07-26 00:28 UTC
From: felixl Assigned:
Status: Open Package: MDB2 (version 2.5.0b3)
PHP Version: 5.3.0 OS: linux x64 (ubuntu 10.10)
Roadmaps: (Not assigned)    
Subscription  


 [2011-07-26 00:28 UTC] felixl (Felix Labrecque)
Description: ------------ between version 2.5.0a1 and 2.5.0a2, the following info was added to the release notes: - added bindname_format option (this is the regexp used to recognize named placeholders in prepared statements) cool but the default regex changed, and now, the named placeholders that I had won't work. previously, a named placeholder beginning with an underscore was working, now it does not. The problem is: file MDB2.php - line 1171 'bindname_format' => '(?:\d+)|(?:[a-zA-Z][a-zA-Z0-9_]*)', previously, the regex was in the prepare function: (line 2950 of MDB2.php) $regexp = '/^.{'.($position+1).'}('.$this->options['bindname_format'].').*$/s'; here is the same line, but in version 2.4.1 $parameter = preg_replace('/^.{'.($position+1).'}([a-z0-9_]+).*$/si', '\\1', $query); The regex was changed from: ^.{xxxx}([a-z0-9_]+).*$ with the case insensitive flag to: ^.{xxx}((?:\d+)|(?:[a-zA-Z][a-zA-Z0-9_]*)).*$ without the case insensitive flag I see now that you make exception when the named placeholder is starting with a digit but I do not understand why the underscore is no longer supported as the first character. Where is the definition of what is the valid format of a named placeholder ? can :123_123_asasdaASDA be a placeholder ? Anyway, here is the fix for line 1171 'bindname_format' => '(?:\d+)|(?:[a-zA-Z_][a-zA-Z0-9_]*)', ou 'bindname_format' => '([a-zA-Z0-9_]+', Test script: --------------- named placeholder starting with an underscore Expected result: ---------------- result from the query Actual result: -------------- getRow will return an MDB2_Error with mysql, mysqli or mssql

Comments