I would like to know whether result set will hold the returned data from the db after fetching data from result set or not. Below is my code. First time when i execute fetchAll i'm able to get the data. But, when i use fetchAll for the second time it return's nothing. I don't understand why.
What i can guess is after fetchAll may be pointer is located at the end of the result set or the result set might be freed. Which one of my guess is right...?
<?php
$Book_DB =new PDO("sqlite:D:/iAnno.data");
$res = $Book_DB->query("select * from chapter");
$res1 = $res->fetchAll();
$res2 = $res->fetchAll();
print_r($res1);
print_r($res2);
?>
The cursor is located at the end.
If your database support scrollable results, you can use PDO::CURSOR_SCROLL and then go backward using PDOStatement::fetch(). But I do not think you can simply "reset" the cursor at the beginning and use fetchAll() again.