<?php
class ServiceVHC {
    public static function getServiceVHCByVhc($idVHC) {
        $query = "SELECT * FROM service_vhc WHERE Id_vhc = :idvhc ORDER BY Km";
        $statement = Connection::getStatement($query);
        $statement->bindParam(":idvhc", $idVHC);
        $statement->execute();
        return $statement->fetchAll();
    }

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

    public static function getServiceVHCByIDAndGreaterKM($id, $km) {
        $query = "SELECT * FROM service_vhc WHERE Id_vhc = :id AND Km > :km ORDER BY Km LIMIT 1";
        $statement = Connection::getStatement($query);
        $statement->bindParam(":id", $id);
        $statement->bindParam(":km", $km);
        $statement->execute();
        return $statement->fetch();
    }

    
}