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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.