Re: Exact equivalent of mysql_data_seek() in PEAR DB

From: Date: Wed, 08 Feb 2006 18:40:55 +0000
Subject: Re: Exact equivalent of mysql_data_seek() in PEAR DB
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-22866@lists.php.net to get a copy of this message
Justin Patrin wrote:
On 2/7/06, Christopher Watson <skygeex@gmail.com> wrote:
I note that PEAR DB added, quite some time ago, a second optional parameter to the fetchRow() method of DB_result to fetch a specific row by number. But that method advances the result pointer to the next row. That's not how mysql_data_seek() works, which establishes the result pointer at the given row, but does not advance it. I have been using the data_seek() method of the mysqli libraries, but have now converted to PEAR DB. Unfortunately, I have a need to set the result point to 0, and _THEN_ iterate through each of the rows from the first to the last. How do I do that in PEAR DB???
Why? You can iterate through the results normally already. I suggest either changing your login to loop through the data only once or looking into perhaps MDB2 (I'm not sure if this is supported in it, but it is worth a look).
There is indeed a seek() method in MDB2. For buffered result sets you can seek forward and backward. For obvious reasons if you enable the unbuffered result option you can only seek forward. regards, Lukas

« previous php.pear.general (#22866) next »