Eugeny89
Eugeny89

Reputation: 3731

mysqli: processing a huge result set

I'm not very strong in databases, so please forgive if the question is dump. I need to process a huge amount of data. It's natural not to load the whole data at one time. How can I retrieve rows in portions of small size (1, 10 or 100). BTW, what portion size is better?

Upvotes: 0

Views: 383

Answers (1)

Fluffeh
Fluffeh

Reputation: 33502

Pulling the data out one row at a time is probably the simplest way to do things. PDO makes it very simple:

<?php
$sth = $dbh->prepare("SELECT name, colour FROM fruit");
$sth->execute();
while($result = $sth->fetch(PDO::FETCH_ASSOC))
{
    // Do stuff to process row.
}
?>

Upvotes: 1

Related Questions