I'm not much of a programmer, but it seems to me that one would never get the first row of a cached query using the PEAR Cache😃B 'fetchRow()' because the $this->cursor increments to 1 before we return the record at cursor position 0
I was able to get around this by making the following changes in the Cache/DB.php, although its not pretty (told you I'm not much of a programmer). See comments for my reasoning.
function fetchRow($fetchmode = DB_FETCHMODE_DEFAULT, $rownum = null) {
if ($fetchmode === DB_FETCHMODE_DEFAULT) {
$fetchmode = $this->fetchmode;
}
if ($fetchmode === DB_FETCHMODE_OBJECT) {
$fetchmode = DB_FETCHMODE_ASSOC;
$return_object = true;
}
if ($rownum === null) {
[COLOR=orangered]// Removed this line because I need cursor position 0 first [/COLOR]
//$this->cursor++;
} else {
$this->cursor = $rownum;
}
if ($rownum < sizeof($this->rows)) {
[COLOR=orangered]// I need the cursor to be 0 only once[/COLOR]
if(!$this->cursor > 1){$this->cursor = 0;}
$row = $this->rows[$this->cursor];
[COLOR=orangered]// I moved the cursor incement call to here [/COLOR]
$this->cursor++;
} else {
return false;
}
Best Regards,
Brian BuscheI need the cursor to be 0 only once[/COLOR]