<?php
class ChassisModel {

    public static function getAll() {
        $query = "SELECT * FROM chassis_model ORDER BY Model";
        $statement = Connection::getStatement($query);
        $statement->execute();
        return $statement->fetchAll();
    }

    
    public static function getChassisModelByNoChassis($noChassis) {
        // TODO improve request ? with a php substring ?

        $query = "SELECT * FROM `chassis_model` WHERE `chassis` LIKE CONVERT(LEFT(:nochasis,CHAR_LENGTH(`chassis`)) USING latin1)";
        $statement = Connection::getStatement($query);
        $statement->bindParam(":nochasis", $noChassis);
        $statement->execute();
        return $statement->fetch();
    }

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

    public static function getChassisModelNotById($id) {
        $query =  "SELECT * FROM chassis_model WHERE Id != :id ORDER BY Chassis";
        $statement = Connection::getStatement($query);
        $statement->bindParam(":id", $id);
        $statement->execute();
        return $statement->fetchAll();
    }
}