<?php
namespace App\Controllers;
use Config\Services;

class Getmodelsbymake extends BaseController{
    private $dbHandle;

    public function index(){
        $this->dbHandle   = \Config\Database::connect();
        $dataToReturn = [];

        $makecode = $this->request->getVar('make');
        
        $R = $this->dbHandle->query("select `model`, `modelcode` from `3V_vehiclemodels` where `makecode` = '{$makecode}' group by `model`, `modelcode` order by `model` ASC");
        $A = $R->getResultArray();
        if(sizeof($A)>0){
            $dataToReturn['status'] = 0;
            $dataToReturn['load'] = $A;
        }else{
            $dataToReturn['status'] = 1;
        }

        return json_encode($dataToReturn, JSON_HEX_APOS | JSON_HEX_QUOT);
    }
}