← Back to team overview

phpdevshell team mailing list archive

[Bug 1091300] Re: 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;

 

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.

** Changed in: phpdevshell
   Importance: Undecided => Low

** Changed in: phpdevshell
       Status: New => Triaged

** Changed in: phpdevshell
     Assignee: (unassigned) => Greg (gregfr)

-- 
You received this bug notification because you are a member of
PHPDevShell, which is subscribed to PHPDevShell.
https://bugs.launchpad.net/bugs/1091300

Title:
  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;

Status in Open Source PHP RAD Framework with UI.:
  Triaged

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(trigger_time, '%Y%m%dT%T') as trigger_time
  from abc;

  
  It's giving error:  
   ../phpdevshell/includes/PHPDS_utils.inc.php(543): vsprintf('???SELECT????jo...', Array)
  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(trigger_time,
  '%Y%m%dT%T') as trigger_time from abc; where id=%(arg_id)u

     New Query:
                  Select  DATE_FORMAT(trigger_time, '%%Y%%m%%dT%%T') as trigger_time from abc; where id=%(arg_id)u 

  felt necessary report  to save others wasting time to debug the code

  thanks,
  Hitesh

To manage notifications about this bug go to:
https://bugs.launchpad.net/phpdevshell/+bug/1091300/+subscriptions


References