Answers for "pdo query fetchAll object"

1

pdo fetchall as object

<?php
 $sth = $dbh->prepare("SELECT name, colour FROM fruit");
 $sth->execute();

 $result = $q->fetchAll(PDO::FETCH_OBJ);
 //$result contains an array of stdObjects
 ?>
Posted by: Guest on April-26-2021

Browse Popular Code Answers by Language