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);
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With