db = $this->load->database("regional", true); $this->db_regional = $this->load->database("regional", true); } function getResult() { try { if (!$this->isLogin) { $this->sys_error("Invalid Token"); exit; } $prm = $this->sys_input; $userid = $this->sys_user['M_UserM_DoctorID']; $patientId = ""; if (isset($prm['patientId'])) { $patientId = trim($prm["patientId"]); } else { echo json_encode([ "status" => "ERR", "message" => 'Patient id is mandatory', ]); exit; } $sqlCek = "SELECT * FROM one_doctor.order_patient WHERE OrderPatientID = ? AND OrderPatientM_DoctorID = ?"; $qryCek = $this->db_regional->query($sqlCek, [intval($patientId), intval($userid)]); if (!$qryCek) { $this->sys_error_db("Error Matching Data"); exit; } $resCek = $qryCek->result_array(); if (count($resCek) >= 1) { $sql = "SELECT oneResultJson FROM one_doctor.one_result WHERE oneResultOrderPatientID = ? "; $qry = $this->db_regional->query($sql, [intval($patientId)]); if (!$qry) { $this->sys_error_db( "Error Get Result " ); exit; } $result = $qry->result_array(); $arrResult = array(); if (count($result) > 0) { foreach ($result as $key => $value) { $jsonResult = json_decode($value['oneResultJson']); $arrResult[] = $jsonResult; } } // $result = array( // $arrResult // ); // "sql" => $this->db->last_query() $this->sys_ok($arrResult); } else { $this->sys_error_db( "Not Your Patient " . $userid ); } } catch (Exception $exc) { $message = $exc->getMessage(); $this->sys_error($message); } } }