db->query($sql,[$qry]); if (!$qry) { echo json_encode(["status" => "ERR", "message" => $this->db->error()["message"], "sql" => $this->db->last_query()]); exit; } $rows = $qry->result_array(); echo json_encode(["status" => "OK" , "rows" => $rows]); } // http://devone.aplikasi.web.id/one-api/training/coba/xquery // di postman data { "query" : "sysmex%"} function xquery() { //ambil user dari $this->sys_user $param = $this->sys_input; $sql = "select * from nat_instrument where Nat_InstrumentName like ? and Nat_InstrumentIsActive = 'Y'"; $qry = $this->db->query($sql,[$param["query"]]); if (!$qry) { echo json_encode(["status" => "ERR", "message" => $this->db->error()["message"], "sql" => $this->db->last_query()]); exit; } $rows = $qry->result_array(); echo json_encode(["status" => "OK" , "rows" => $rows]); } function update() { //begin transaction $this->db->trans_begin(); $param = $this->sys_input; $sql = "insert into training_test(trainingTestNote) values(?)"; $qry = $this->db->query($sql,[$param["note"]]); if (!$qry) { $this->db->trans_rollback(); echo json_encode(["status" => "ERR", "message" => $this->db->error()["message"], "sql" => $this->db->last_query()]); exit; } $sql = "update training_test set trainingTestNote= ?"; $qry = $this->db->query($sql,[$param["note"]]); if (!$qry) { $this->db->trans_rollback(); echo json_encode(["status" => "ERR", "message" => $this->db->error()["message"], "sql" => $this->db->last_query()]); exit; } $this->db->trans_commit(); echo json_encode(["status" => "OK"]); } }