Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2012
    Location
    mostly harmless
    Posts
    1,809
    Plugin Contributions
    8

    Default [Fixed 1.6.0]Query Factory

    I've been using a modified version of this class for quite awhile since one of my clients uses a large amount of file caching (Hosting Restrictions). The following changes fix a few issues I've run into. If anyone wants to see the final versions of these files I am using, a copy has been included in the latest "Ultimate SEO" plugin.


    When calling Execute() using zf_cache=true the result object is not always returned.
    Starting at line 151 change code from:
    PHP Code:
          if (sizeof($zp_result_array) > ) {
            
    $obj->EOF false;
            while (list(
    $key$value) = each($zp_result_array[0])) {
              
    $obj->fields[$key] = $value;
            }
            return 
    $obj;
          } else {
            
    $obj->EOF true;
          } 
    To:
    PHP Code:
          if (sizeof($zp_result_array) > ) {
            
    $obj->EOF false;
            while (list(
    $key$value) = each($zp_result_array[0])) {
              
    $obj->fields[$key] = $value;
            }
          } else {
            
    $obj->EOF true;
          }
          return 
    $obj
    Some functions in the "queryFactoryResult" class depend on the object containing a mysql resource. This breaks some code when using cached objects, since they do not always include a mysql resource.

    Move line 178 to just before line 205. This is required for the code changes below to work.
    Code:
    #178  $obj->is_cached = true;
    Starting at line 509 change code from:
    PHP Code:
      function RecordCount() {
        return @
    mysql_num_rows($this->resource);
      }

      function 
    Move($zp_row) {
        global 
    $db;
        if (@
    mysql_data_seek($this->resource$zp_row)) {
          
    $zp_result_array = @mysql_fetch_array($this->resource);
            while (list(
    $key$value) = each($zp_result_array)) {
              
    $this->fields[$key] = $value;
            }
          @
    mysql_data_seek($this->resource$zp_row);
          
    $this->EOF false;
          return;
        } else {
          
    $this->EOF true;
          
    $db->set_error(mysql_errno(),mysql_error());
        }
      } 
    To:
    PHP Code:
      function RecordCount() {
        if (
    $this->is_cached)
          return 
    sizeof($this->result);
          return @
    mysql_num_rows($this->resource);
      }

      function 
    Move($zp_row) {
        global 
    $db;
        if (
    $this->is_cached) {
            if(
    $zp_row >= sizeof($this->result)) {
                
    $this->cursor sizeof($this->result);
                
    $this->EOF true;
            }
            else {
                
    $this->cursor $zp_row;
                while(list(
    $key$value) = each($this->result[$this->cursor])) {
                  
    $this->fields[$key] = $value;
                }
                
    $this->EOF false;
            }
        }
        else if (@
    mysql_data_seek($this->resource$zp_row)) {
          
    $zp_result_array = @mysql_fetch_array($this->resource);
            while (list(
    $key$value) = each($zp_result_array)) {
              
    $this->fields[$key] = $value;
            }
          @
    mysql_data_seek($this->resource$zp_row);
          
    $this->EOF false;
          return;
        } else {
          
    $this->EOF true;
          
    $db->set_error(mysql_errno(),mysql_error());
        }
      } 
    Last edited by lhungil; 24 Sep 2012 at 04:45 PM.

  2. #2
    Join Date
    Jun 2003
    Location
    Newcastle UK
    Posts
    2,896
    Blog Entries
    2
    Plugin Contributions
    2

    Default Re: Query Factory

    Hi,

    Thanks for the report, we will move this into our change management system for further investigation and possible inclusion into core.

  3. #3
    Join Date
    Jun 2003
    Location
    Newcastle UK
    Posts
    2,896
    Blog Entries
    2
    Plugin Contributions
    2

    Default Re: Query Factory

    Hi,

    Code has been committed to v1.6.0

    See https://github.com/zencart/zencart/c...4f845ca345f247

 

 

Similar Threads

  1. Replies: 1
    Last Post: 19 Sep 2011, 04:16 PM
  2. Xampp 1.72 Query Factory Php Error
    By CRYSTALDOLL in forum General Questions
    Replies: 6
    Last Post: 19 Sep 2009, 02:33 PM
  3. query factory error
    By ethanolic in forum General Questions
    Replies: 12
    Last Post: 20 Sep 2007, 02:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR