mysql_data_seek follow up

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lawrence

    #1

    mysql_data_seek follow up

    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 dsRowIntoArrayW ithStringIndex( &$dsResult, $index=false) {
    // 11-04-03 - this first lines test to see if anything came back
    from the datastore
    if (is_resource($d sResult)) {
    $this->resultsObjec t->debugNotes(" In
    dsRowIntoArrayW ithStringIndex( ), in McFormatResults MySql, 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($in dex)) {
    $success = mysql_data_seek ($dsResult, $index);
    if ($success) {
    $this->resultsObjec t->debugNotes(" In
    dsRowIntoArrayW ithStringIndex( ), in McFormatResults MySql, we
    successfully set the database resource pointer to the index of
    $index.");
    } else {
    $this->resultsObjec t->addToErrorResu lts("In
    dsRowIntoArrayW ithStringIndex( ), in McFormatResults MySql, we failed to
    set the database resource pointer to the index of $index.");
    }
    }
    $row = mysql_fetch_ass oc($dsResult);
    $row = $this->stripslashesFr omEntryWithKeyI ndex($row);
    return $row;
    } else {
    $this->resultsObjec t->addToErrorResu lts("In
    dsRowIntoArrayW ithStringIndex( ), in the class McFormatResults MySql, 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 getRowAsArrayWi thStringIndex() , in the class
    McGetDatastoreR esults, we were handed a resource pointer for a
    database result, and will now hand it to mcgetdatastorer esultsmysql.
    The index, if there is one, is ' 1 '.

    In dsRowIntoArrayW ithStringIndex( ), in McFormatResults MySql, the index
    is ' 1 '. If it is numberic, we will try to use it as an index to
    access the database return.

    In dsRowIntoArrayW ithStringIndex( ), in McFormatResults MySql, we failed
    to set the database resource pointer to the index of 1.

    In stripslashesFro mEntryWithKeyIn dex(), in the class
    McFormatResults MySql, 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.
Working...