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()?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.