function getChats($dbh) { $stmt = $dbh->prepare("select * from " . chat::$table_name . " ORDER BY id desc limit 100"); $stmt->execute(); $result = array(); while ($row = $stmt->fetch()) { $p = new chat(); $p->copyFromRow($row); $result[] = $p; } return $result; }