Answer the question
In order to leave comments, you need to log in
There is a big table. How to select from it all the data in a cycle, in batches of 10 records?
It is clear that you need to use LIMIT and OFFSET, but I don’t understand how to shift OFFSET?
Explain the principle or poke into a code example.
Thank you.
Answer the question
In order to leave comments, you need to log in
<?php
$limit = 10000;
$offset = 0;
do {
$data = $db->query("SELECT * FROM `tbl` ORDER BY `id` ASC LIMIT $limit OFFSET $offset")->fetchAll();
$offset += count($data);
}
while(count($data));
Not necessary.
How much data you need - so much and request, all at once, without any limits.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question