DB Cursor fetching in Web Applications
I never understood this: in web development whe[n|re] does it make sense to fetch results one by one?
I mean, why shou开发者_开发问答ld 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.
精彩评论