This is a follow up to my last post. I've been working trying to
figure this out, to no avail. I've made it so that I could pass an
index down and use mysql_data_seek to force the database resource
pointer (the result resource) to the row that I want. But its not
working. This is the method:
/**
* 11-04-03 - it is important that the resource which points to the
returned dataset gets passed into this method
* by reference, not by copy, or else, in the outside code that is
calling this method, the pointer in that resource
* will never advance to the next resource row.
*/
function dsRowIntoArrayWithStringIndex(&$dsResult, $index=false) {
// 11-04-03 - this first lines test to see if anything came back
from the datastore
if (is_resource($dsResult)) {
$this->resultsObject->debugNotes("In
dsRowIntoArrayWithStringIndex(), in McFormatResultsMySql, the index is
' $index '. If it is numeric, we will try to use it as an index to
access the database return.");
if (is_numeric($index)) {
$success = mysql_data_seek($dsResult, $index);
if ($success) {
$this->resultsObject->debugNotes("In
dsRowIntoArrayWithStringIndex(), in McFormatResultsMySql, we
successfully set the database resource pointer to the index of
$index.");
} else {
$this->resultsObject->addToErrorResults("In
dsRowIntoArrayWithStringIndex(), in McFormatResultsMySql, we failed to
set the database resource pointer to the index of $index.");
}
}
$row = mysql_fetch_assoc($dsResult);
$row = $this->stripslashesFromEntryWithKeyIndex($row);
return $row;
} else {
$this->resultsObject->addToErrorResults("In
dsRowIntoArrayWithStringIndex(), in the class McFormatResultsMySql, we
expected the method to be handed a pointer to a database return
resource, but we were not.");
}
}
These are some of the error messages that my resultsObject is printing
out (the 3rd one is the failure message from the method above):
---------------------------------------------
In getRowAsArrayWithStringIndex(), in the class
McGetDatastoreResults, we were handed a resource pointer for a
database result, and will now hand it to mcgetdatastoreresultsmysql.
The index, if there is one, is ' 1 '.
In dsRowIntoArrayWithStringIndex(), in McFormatResultsMySql, the index
is ' 1 '. If it is numberic, we will try to use it as an index to
access the database return.
In dsRowIntoArrayWithStringIndex(), in McFormatResultsMySql, we failed
to set the database resource pointer to the index of 1.
In stripslashesFromEntryWithKeyIndex(), in the class
McFormatResultsMySql, we expected the method to be handed an array,
but it was not.
----------------------------------------------
The index, of course, is 0 during the first loop, 1 during the second
loop, and 2 during the 3rd loop. I'm coping and pasting these
particular error messages that get printed out during the second loop.
Again, when I use phpMyAdmin to run the same query, I get 3 returns.