I have this sample query:
$STH = $DBH->query("SELECT id FROM table"); I want to get the first row and then loop and display all rows. So I use the following to get the first row:
$STH->setFetchMode(PDO::FETCH_ASSOC); $first_row = $STH->fetch(); $first_row = $first_row['id']; I use while loop to display all rows again:
while ($list = $STH->fetch()) { $id = $list['id']; echo $id; } Now the while skips the first row and I want it to be displayed. Is there an equivalent to mysql_data_seek to reset the pointer again to the first row? I know fetchall can be used but it's bad on memory and wasteful. I could also run the query and limit to 1 but this is not recommended as I have a query that joins multiple tables and would be very slow. Is there any other solution?
Thanks