Avoid repetition on each fetch in upcoming usage.
function __construct($config, $options = [])
{
- $options += [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ];
+ $options += [
+ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
+ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ,
+ ];
$this->dbh = new PDO($config, NULL, NULL, $options);
}
print '<ul class="replies">';
-while ($row = $query->fetch(PDO::FETCH_OBJ)) {
+while ($row = $query->fetch()) {
$rowuser = new User("profile/{$row->author}");
print '<li>';
printf('<strong>%s</strong> <small class=date>%s</small>',