66 lines
2.1 KiB
PHP
66 lines
2.1 KiB
PHP
<?php
|
|
class Coba extends MY_Controller {
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
function index() {
|
|
echo "Api: Training Playground";
|
|
}
|
|
// http://devone.aplikasi.web.id/one-api/training/coba/query/sysmex
|
|
// $qry = sysmex
|
|
function query($qry) {
|
|
$qry = "%$qry%";
|
|
$sql = "select * from nat_instrument where Nat_InstrumentName like ? and Nat_InstrumentIsActive = 'Y'";
|
|
$qry = $this->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"]);
|
|
}
|
|
}
|