diff --git a/library/Director/Data/Db/DbObject.php b/library/Director/Data/Db/DbObject.php index fb373789..35fa2e21 100644 --- a/library/Director/Data/Db/DbObject.php +++ b/library/Director/Data/Db/DbObject.php @@ -738,6 +738,26 @@ abstract class DbObject return $obj; } + public static function loadAll(DbConnection $connection) + { + $objects = array(); + $class = get_called_class(); + $db = $connection->getConnection(); + + $dummy = new $class(); + $select = $db->select()->from($dummy->table); + $rows = $db->fetchAll($select); + + foreach ($rows as $row) { + $obj = new $class(); + $obj->connection = $connection; + $obj->setDb($db)->setDbProperties($row); + $objects[] = $obj; + } + + return $objects; + } + public static function exists($id, DbConnection $connection) { $class = get_called_class();