Reputation: 226
I'm confused with using fetch()
and fetchAll
in a PDO statement. I went through the php.net
manual and that made it more confusing. Even went through the suggestions provided in
stackoverflow. If anyone could help me understand it the easy way, it would be great.
For example
$result = $stmt->fetchAll(PDO::FETCH_OBJ);
$result = $stmt->fetch(PDO::FETCH_OBJ);
Upvotes: 10
Views: 22746
Reputation: 62466
The documentation says:
PDOStatement::fetch — Fetches the next row from a result set
PDOStatement::fetchAll — Returns an array containing all of the result set rows
Upvotes: 14