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

class Getenginesbydetails extends BaseController{
    private $dbHandle;

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

        $make = $this->request->getVar('make');
        $model = $this->request->getVar('model');
        
        $R = $this->dbHandle->query("select `engine`, `engdesc` from `3V_supplementary` where `makecode` = '{$make}' and `modelcode` = '{$model}' group by `engine`, `engdesc` order by `engine` 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);
    }
}