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

class Setfieldvalue extends BaseController{
private $dbHandle;

    public function index(){
        $this->dbHandle   = \Config\Database::connect();
        $dataToReturn = [];
        
        $source = $this->request->getVar('source');
        $rowid = $this->request->getVar('rowid');
        $column = $this->request->getVar('column');
        $value = $this->request->getVar('value');
        
        $this->dbHandle->query("update `{$source}` set `{$column}`='{$value}' where `id`='{$rowid}'");
        $E = $this->dbHandle->error();
        
        $dataToReturn['status'] = $E['code'];
        $dataToReturn['load'] = $value;

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