Jump to content

MySQL Internal Pointer Position


The Little Guy

Recommended Posts

Is there a way to get the mysql's internal pointer position? I have searched Google, found this:

 

<?php 
function mysql_pointer_position($result_set) { 
        $num_rows = mysql_num_rows($result_set); 
        $i = 0; 
        while($result = mysql_fetch_array($result_set)) { 
            $i++; 
        } 
        $pointer_position = $num_rows - $i; 

//Return pointer to original position 
        if($pointer_position <= $num_rows - 1) { 
            mysql_data_seek($result_set, $pointer_position); 
        } 
        return $pointer_position; 
    } 
?>

 

But I don't really like it. Is there a better way to find the current position of the internal pointer?

Link to comment
https://forums.phpfreaks.com/topic/246206-mysql-internal-pointer-position/
Share on other sites

What are you trying to accomplish that requires you to get the pointer position? My guess is there is a more efficient method to do what you want.

 

But, if you really need to know the pointer position (which I really doubt), then build a class to use to replace the mysql_fetch_ functions that will maintain the pointer position as a property in the class.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.