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) > 0 ) {
$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) > 0 ) {
$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());
}
}
Bookmarks