Hi,
Which is the equivalent of mysql_data_seek using pdo objects? Can you give me an example?
Thanks!
Hi,
Which is the equivalent of mysql_data_seek using pdo objects? Can you give me an example?
Thanks!
I found the answer to my question in this thread: http://stackoverflow.com/questions/278259/is-it-possible-to-rewind-a-pdo-result
The usual answer is: do your data seek directly in the array PDOStatement::fetchAll... But it is WRONG IF the query fetches a lot of data (!).
There are 2 real solutions,
1) if database permits use PDO::FETCH_ORI_ABS or PDO::FETCH_ORI_REL, example,
$result = $sth->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_ABS, 973);
2) use the database solution (a kind of pagination). Example:
SELECT a, b FROM table OFFSET 973 LIMIT 1