I never understood this: in web development whe[n|re] does it make sense to fetch results one by one?
I mean, why should I use PDOStatement->fetch*()
when I can use PDOStatement->fetchAll()
?
I never understood this: in web development whe[n|re] does it make sense to fetch results one by one?
I mean, why should I use PDOStatement->fetch*()
when I can use PDOStatement->fetchAll()
?
fetchAll()
will fetch all the results into one big array.
With very large result sets, it could exceed the PHP script's memory limit.
A pure fetch()
will fetch each record one by one, neutralizing that danger.
That's the only reason not to use fetchAll()
I can think of.