problem with invokeQueryWith() function while using % as part of the query e.g. Select DATE_FORMAT(trigger_time, '%Y%m%dT%T') as trigger_time from abc;
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
PHPDevShell |
Triaged
|
Low
|
Greg |
Bug Description
Issue:
=====
This is the issue we found during our project development using invokeQueryWith() function to invoke a query which involve % sign as part of query.
e.g. Select DATE_FORMAT(
It's giving error:
../phpdevshell
Excetion -->vsprintf(): Too few arguments
Explanation:
=========
The issue is we use vsprintf to replace named parameters in query with arguments passed in query. The syntax of query required '%(abcd)s' format to specify the replacement parameter. Internally, phpdevshell try to mach that replacement parameters and replace it using vsprintf function.
Somehow there is a bug in vsprintf() method of php and it tries to replace parameters with arguments pass to query starting with whereever it sees % sign within the query. Hench forth it runs sort of replacement arguments or endup replacing arguments at wrong place and throwing error: vsprintf(): Too few arguments
Solution:
=======
Solution 1:
-------------- Report bug to php to fix it in vsprintf()
Solution 2:
----------------
Update documentation of phpdevshell database part, to update users to precede % with another % sign as escape character while executing query involving named parameters.
e.g. Original Query: Select DATE_FORMAT(
New Query:
felt necessary report to save others wasting time to debug the code
thanks,
Hitesh
Thanks for your contribution.
Your solution #2 is the correct one.
However, I'll study the framework function to see if it can be determined at runtime without too much penalty on the performances.