What is alternative to fetchall for real time loop?
Consider this:
$query = $db->prepare("SELECT * FROM record WHERE status = 0");
$query->execute();
$Record = $query->fetchall(PDO::FETCH_ASSOC);
foreach ($Record as $row) {
echo $row['name'];
sleep(5)
}
While its looping and echo‘ing, I updated status = 1 from the console but it will still show the record which it shouldn’t.
How about a simple
fetch(): https://www.php.net/manual/en/pdostatement.fetch.php