<?php
class Category {
    public static function getTopCategories() {
        $query = "SELECT * FROM categories WHERE ParentID IS NULL";
        $statement = Connection::getStatement($query);
        $statement->execute();
        return $statement->fetchAll();
    }

    public static function getCategoryByID($id) {
        $query = "SELECT * FROM categories WHERE ID = :id";
        $statement = Connection::getStatement($query);
        $statement->bindParam(":id", $id);
        $statement->execute();
        return $statement->fetch();
    }    

    public static function getCategoryByParent($parentId) {
        $query = "SELECT * FROM categories WHERE ParentID = :id";
        $statement = Connection::getStatement($query);
        $statement->bindParam(":id", $parentId);
        $statement->execute();
        return $statement->fetchAll();
    }   
}