Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

internal result pointer

Status
Not open for further replies.

smoker616

Programmer
May 2, 2003
14
0
0
US
I want to set back the internal result pointer from a mysql_query by one. I looked at the code behind mysql_data_seek and it seems that when you do a select in a mysql_query it returns a linked list of some sort. when you call mysql_data_seek it traverses the linked list x times where x is the specified offset. Does anyone know how this is set up. I just want to move the pointer backwards one.
The code i tried was
$result = mysql_query('SELECT * ...');
mysql_fetch_row($result);
$result->data_cursor = $result_array->data->data->prev;
$result_array->current_row = 0;

This doesnt work but, this is similar to how mysql_data_seek works.
 
Sorry, reading more carefully your post I see that you already know this function...
Gaetano
 
First of all, in your code $result is not an object, so all the object manipulation you're trying to do can't work.

But I think you're misunderstanding the offset parameter used in mysql_data_seek*(). The offset is not a number of linked list entries to traverse, but rather the absolute number of the row in the result set.

If you keep track of how many rows you've already fetched, then decrement that counter and use it as the offset parameter in mysql_data_seek().

Want the best answers? Ask the best questions: TANSTAAFL!
 
Well i decided to just store the row's info into another variable. Using data_seek is just too darn inefficent. upon looking at the C code it will go to the start of the linked list and then move through it. So if im at row 10,000 to go back one would take at least 9999 iterations
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top