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

class Geteditablesourcefields extends BaseController{
    private $dbHandle;

    public function index(){
        $this->dbHandle   = \Config\Database::connect();
        $dataToReturn = [];
        
        $source = $this->request->getVar('source');
        
        $A = $this->dbHandle->getFieldNames($source);
        if(sizeof($A)>0){
            $dataToReturn['status'] = 0;
            $dataToReturn['load'] = $A;
        }else{
            $dataToReturn['status'] = 1;
        }
        
        return json_encode($dataToReturn, JSON_HEX_APOS | JSON_HEX_QUOT);
    }
}