function getCategories() { $categories = array(); $db = new ServerDatabase(); $db->newQuery('SELECT id, title, parent FROM category'); $rows = $db->execute(); foreach ($rows as $row) { $category = new Category(); $category->fillFromArray($row); $categories[] = $category; } return $categories; }