Loading ...
Sorry, an error occurred while loading the content.
 

Function PrepareQuery($query) method

Expand Messages
  • pierre-henri@wanadoo.be
    Hello, I met a problem using this feature the ? in the query. Ex: If I use a mix of varchar and blob in a query, the query looks like this: insert into table
    Message 1 of 4 , Sep 17, 2001
      Hello,

      I met a problem using this feature the ? in the query. Ex:

      If I use a mix of varchar and blob in a query, the query looks like
      this:

      insert into table (id,varchar_item,blob_item) values (0,"Who are
      you ?",?)

      the prepares match both ? as blobs, but it should only get the second
      one.

      So Sergio Zia (sergio.zia@...) modified the methods like this
      to solve this problem.

      Hope it helps.


      Function PrepareQuery($query)
      {
      $positions=array();

      $counted=preg_match_all("/([=\(,]\s*\?\s*[,\)wW])/",$query,$regs);
      $position=-1;
      for($i=0;$i<$counted;$i++)
      {
      $position=strpos($query,$regs[0][$i],$position+1)+strpos($regs[0]
      [$i],"?",0);
      $positions[]=$position;
      }
      $this->prepared_queries[]=array(
      "Query"=>$query,
      "Positions"=>$positions,
      "Values"=>array()
      );
      $prepared_query=count($this->prepared_queries);
      if($this->selected_row_limit>0)
      {
      $this->prepared_queries[$prepared_query]["First"]=$this-
      >first_selected_row;
      $this->prepared_queries[$prepared_query]["Limit"]=$this-
      >selected_row_limit;
      }
      return($prepared_query);
      }
    • mlemos@acm.org
      Hello, ... second ... Yes, I meant to fix this but never made time. I was willing to integrate the fix, but it uses Perl regular expressions and not everybody
      Message 2 of 4 , Sep 18, 2001
        Hello,

        --- In metabase-dev@y..., pierre-henri@w... wrote:
        > Hello,
        >
        > I met a problem using this feature the ? in the query. Ex:
        >
        > If I use a mix of varchar and blob in a query, the query looks like
        > this:
        >
        > insert into table (id,varchar_item,blob_item) values (0,"Who are
        > you ?",?)
        >
        > the prepares match both ? as blobs, but it should only get the
        second
        > one.
        >
        > So Sergio Zia (sergio.zia@w...) modified the methods like this
        > to solve this problem.

        Yes, I meant to fix this but never made time.

        I was willing to integrate the fix, but it uses Perl regular
        expressions and not everybody has that module built with PHP. Could
        this be rewritten using normal regular expressions or something else?

        Regards,
        Manuel Lemos
      • Peter Bowyer
        ... I think _almost_ everyone has PCRE support these days. Therefore couldn t we assume that they do, and just use it? It s faster, so would be beneficial.
        Message 3 of 4 , Sep 18, 2001
          At 05:19 PM 9/18/01 +0000, you wrote:
          >I was willing to integrate the fix, but it uses Perl regular
          >expressions and not everybody has that module built with PHP. Could
          >this be rewritten using normal regular expressions or something else?

          I think _almost_ everyone has PCRE support these days. Therefore couldn't
          we assume that they do, and just use it? It's faster, so would be beneficial.

          Regards,
          Peter.

          --oOo--
          Narrow Gauge on the web - photos, directory and forums!
          http://www.narrow-gauge.co.uk
          --oOo--
          Peter's web page - Scottish narrow gauge in 009
          http://members.aol.com/reywob/
          --oOo--
        • mlemos@acm.org
          Hello, ... I can use the code function if the preg_match_all function is available, but I still need some alternative code that works when the function is not
          Message 4 of 4 , Sep 18, 2001
            Hello,

            --- In metabase-dev@y..., Peter Bowyer <reywob@f...> wrote:
            > At 05:19 PM 9/18/01 +0000, you wrote:
            > >I was willing to integrate the fix, but it uses Perl regular
            > >expressions and not everybody has that module built with PHP. Could
            > >this be rewritten using normal regular expressions or something else?
            >
            > I think _almost_ everyone has PCRE support these days. Therefore couldn't
            > we assume that they do, and just use it? It's faster, so would be beneficial.

            I can use the code function if the preg_match_all function is available, but I still need some alternative code that works when the function is not available.

            Regards,
            Manuel Lemos
          Your message has been successfully submitted and would be delivered to recipients shortly.