function getPostComments($dbh, $id) { $stmt = $dbh->prepare("select * from " . comments::$table_name . " WHERE postid = :postid ORDER BY id;"); $stmt->bindParam(":postid", $id); $stmt->execute(); $result = array(); while ($row = $stmt->fetch()) { $p = new comments(); $p->copyFromRow($row); $result[] = $p; } return $result; }