db_onedev = $this->load->database("onedev", true); } function lookupabnormalbyname(){ try { //# cek token valid if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $prm = $this->sys_input; $testname = $prm['testname']; $methodename = $prm['methodename']; $sexid = $prm['sexid']; $flagid = $prm['flagid']; $filter = ''; if(isset($sexid)){ $filter .= "AND ($sexid = 0 or ($sexid > 0 and Nat_SexID = $sexid)) "; } if(isset($flagid)){ $filter .= "AND ($flagid = 0 or ($flagid > 0 and Nat_FlagID = $flagid))"; } $limit = ''; if($all == 'N'){ $limit = ' LIMIT 10'; } $number_limit = 10; $number_offset = ($prm['current_page'] - 1) * $number_limit ; $sql = "select COUNT(*) as total FROM(SELECT * from nat_normalvalue LEFT JOIN nat_advice_abnormal ON Nat_NormalValueID = Nat_AdviceAbnormalNat_NormalValueID AND Nat_AdviceAbnormalIsActive = 'Y' LEFT JOIN nat_sex ON Nat_NormalValueNat_SexID = Nat_SexID JOIN nat_test ON Nat_NormalValueNat_TestID = Nat_TestID JOIN nat_methode ON Nat_NormalValueNat_MethodeID = Nat_MethodeID AND Nat_MethodeIsActive = 'Y' JOIN nat_normalvaluetype ON Nat_NormalValueNat_NormalValueTypeID = Nat_NormalValueTypeID LEFT JOIN nat_flag ON Nat_NormalValueNat_FlagID = Nat_FlagID WHERE Nat_NormalValueIsActive = 'Y' AND Nat_NormalValueIsAbnormal = 'Y' AND Nat_TestName like '%{$testname}%' AND Nat_MethodeName like '%{$methodename}%' $filter GROUP BY Nat_NormalValueID) a"; // $total = $this->db_onedev->query($sql,$sql_param)->row()->total; $query = $this->db_onedev->query($sql); //echo $this->db_onedev->last_query(); $tot_count = 0; $tot_page = 0; if ($query) { $tot_count = $query->result_array()[0]["total"]; $tot_page = ceil($tot_count/$number_limit); } else { $this->sys_error_db("nat_normalvalue count", $this->db_onedev); exit; } $sql = "SELECT nat_normalvalue.*, Nat_NormalValueID as id, Nat_NormalValueID, IFNULL(Nat_AdviceAbnormalID,0) as Nat_AdviceAbnormalID, Nat_TestName, Nat_SexID, Nat_SexName, Nat_MethodeID, Nat_MethodeName, Nat_NormalValueTypeID, Nat_NormalValueTypeName, Nat_FlagID, Nat_FlagName, Nat_NormalValueMinAge, Nat_NormalValueMaxAge, CASE WHEN Nat_NormalValueMinAgeInclusive = 'Y' AND Nat_NormalValueMaxAgeInclusive = 'Y' THEN CONCAT(Nat_NormalValueMinAge,' - ',Nat_NormalValueMaxAge,' (',Nat_NormalValueAgeUnit,')') WHEN Nat_NormalValueMinAgeInclusive = 'Y' AND Nat_NormalValueMaxAgeInclusive = 'N' THEN CONCAT(Nat_NormalValueMinAge,' > ',Nat_NormalValueMaxAge,' (',Nat_NormalValueAgeUnit,')') WHEN Nat_NormalValueMinAgeInclusive = 'N' AND Nat_NormalValueMaxAgeInclusive = 'Y' THEN CONCAT(Nat_NormalValueMinAge,' < ',Nat_NormalValueMaxAge,' (',Nat_NormalValueAgeUnit,')') ELSE '-' END as Nat_NormalValueAge, CASE WHEN Nat_NormalValueMinValueInclusive = 'Y' AND Nat_NormalValueMaxValueInclusive = 'Y' THEN CONCAT(Nat_NormalValueMinValue,' - ',Nat_NormalValueMaxValue) WHEN Nat_NormalValueMinValueInclusive = 'Y' AND Nat_NormalValueMaxValueInclusive = 'N' THEN CONCAT(Nat_NormalValueMinValue,' > ',Nat_NormalValueMaxValue) WHEN Nat_NormalValueMinValueInclusive = 'N' AND Nat_NormalValueMaxValueInclusive = 'Y' THEN CONCAT(Nat_NormalValueMinValue,' < ',Nat_NormalValueMaxValue) ELSE '-' END as Nat_NormalValueValue, CASE WHEN Nat_NormalValueAgeUnit = 'HARI' THEN '1' WHEN Nat_NormalValueAgeUnit = 'BULAN' THEN '2' WHEN Nat_NormalValueAgeUnit = 'TAHUN' THEN '3' ELSE '4' END as ageunit, IF(Nat_NormalValueIsAbnormal = 'N',Nat_NormalValueID,Nat_NormalValueParentID) as parentid FROM nat_normalvalue LEFT JOIN nat_advice_abnormal ON Nat_NormalValueID = Nat_AdviceAbnormalNat_NormalValueID AND Nat_AdviceAbnormalIsActive = 'Y' LEFT JOIN nat_sex ON Nat_NormalValueNat_SexID = Nat_SexID JOIN nat_test ON Nat_NormalValueNat_TestID = Nat_TestID JOIN nat_methode ON Nat_NormalValueNat_MethodeID = Nat_MethodeID AND Nat_MethodeIsActive = 'Y' JOIN nat_normalvaluetype ON Nat_NormalValueNat_NormalValueTypeID = Nat_NormalValueTypeID LEFT JOIN nat_flag ON Nat_NormalValueNat_FlagID = Nat_FlagID WHERE Nat_NormalValueIsActive = 'Y' AND Nat_NormalValueIsAbnormal = 'Y' AND Nat_TestName like '%{$testname}%' AND Nat_MethodeName like '%{$methodename}%' $filter GROUP BY Nat_NormalValueID ORDER BY Nat_NormalValueNat_SexID ASC, ageunit ASC, Nat_NormalValueMinAge ASC, Nat_NormalValueMaxAge ASC, parentid ASC limit $number_limit offset $number_offset"; $sql_param = array($search); $query = $this->db_onedev->query($sql); // echo $this->db_onedev->last_query(); if ($query) { $rows = $query->result_array(); } else { $this->sys_error_db("nat_normalvalue select"); exit; } $result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows); $this->sys_ok($result); } catch(Exception $exc) { $message = $exc->getMessage(); $this->sys_error($message); } } function lookupadvicebyid(){ try { //# cek token valid if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $prm = $this->sys_input; $id = $prm['id']; $adviceina = $prm['adviceina']; $adviceeng = $prm['adviceeng']; $status = $prm['status']; $all = $prm['all']; $filter = ''; if($status != 'A'){ $filter .= "AND status = '{$status}' "; }else{ $filter .= ""; } $limit = ''; if($all == 'N'){ $limit = ' LIMIT 10'; } $number_limit = 10; $number_offset = ($prm['current_page'] - 1) * $number_limit ; $sql = "select COUNT(*) as total FROM(SELECT *, IF(IFNULL(Nat_AdviceAbnormalID,0) > 0 , 'Y', 'N') as status from nat_advice LEFT JOIN nat_advice_abnormal ON Nat_AdviceID = Nat_AdviceAbnormalNat_AdviceID AND Nat_AdviceAbnormalNat_NormalValueID = $id AND Nat_AdviceAbnormalIsActive = 'Y' LEFT JOIN nat_normalvalue ON Nat_AdviceAbnormalNat_NormalValueID = Nat_NormalValueID AND Nat_NormalValueIsActive = 'Y' WHERE Nat_AdviceIsActive = 'Y' GROUP BY Nat_AdviceID) a WHERE Nat_AdviceIna like '%{$adviceina}%' AND Nat_AdviceEng like '%{$adviceeng}%' $filter"; // $total = $this->db_onedev->query($sql,$sql_param)->row()->total; $query = $this->db_onedev->query($sql); //echo $this->db_onedev->last_query(); $tot_count = 0; $tot_page = 0; if ($query) { $tot_count = $query->result_array()[0]["total"]; $tot_page = ceil($tot_count/$number_limit); } else { $this->sys_error_db("nat_advice count", $this->db_onedev); exit; } $sql = "SELECT * FROM(select Nat_AdviceID as id, Nat_AdviceID, Nat_AdviceIna, Nat_AdviceEng, Nat_AdviceAbnormalID, Nat_AdviceAbnormalNat_NormalValueID, Nat_AdviceAbnormalNat_AdviceID, IF(IFNULL(Nat_AdviceAbnormalID,0) > 0 , 'Y', 'N') as status from nat_advice LEFT JOIN nat_advice_abnormal ON Nat_AdviceID = Nat_AdviceAbnormalNat_AdviceID AND Nat_AdviceAbnormalNat_NormalValueID = $id AND Nat_AdviceAbnormalIsActive = 'Y' LEFT JOIN nat_normalvalue ON Nat_AdviceAbnormalNat_NormalValueID = Nat_NormalValueID AND Nat_NormalValueIsActive = 'Y' WHERE Nat_AdviceIsActive = 'Y') a WHERE Nat_AdviceIna like '%{$adviceina}%' AND Nat_AdviceEng like '%{$adviceeng}%' $filter GROUP BY Nat_AdviceID ORDER BY Nat_AdviceID ASC limit $number_limit offset $number_offset"; $sql_param = array($search); $query = $this->db_onedev->query($sql); //echo $this->db_onedev->last_query(); if ($query) { $rows = $query->result_array(); } else { $this->sys_error_db("nat_advice select"); exit; } $result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows); $this->sys_ok($result); } catch(Exception $exc) { $message = $exc->getMessage(); $this->sys_error($message); } } function listingadvice(){ try { //# cek token valid if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $prm = $this->sys_input; $adviceina = $prm['adviceina']; $adviceeng = $prm['adviceeng']; $all = $prm['all']; $limit = ''; if($all == 'N'){ $limit = ' LIMIT 10'; } $number_limit = 10; $number_offset = ($prm['current_page'] - 1) * $number_limit ; $sql = "select COUNT(*) as total from nat_advice WHERE Nat_AdviceIsActive = 'Y' AND Nat_AdviceIna like '%{$adviceina}%' AND Nat_AdviceEng like '%{$adviceeng}%'"; // $total = $this->db_onedev->query($sql,$sql_param)->row()->total; $query = $this->db_onedev->query($sql); //echo $this->db_onedev->last_query(); $tot_count = 0; $tot_page = 0; if ($query) { $tot_count = $query->result_array()[0]["total"]; $tot_page = ceil($tot_count/$number_limit); } else { $this->sys_error_db("nat_advice count", $this->db_onedev); exit; } $sql = "SELECT * from nat_advice WHERE Nat_AdviceIsActive = 'Y' AND Nat_AdviceIna like '%{$adviceina}%' AND Nat_AdviceEng like '%{$adviceeng}%' ORDER BY Nat_AdviceID ASC limit $number_limit offset $number_offset"; $sql_param = array($search); $query = $this->db_onedev->query($sql); //echo $this->db_onedev->last_query(); if ($query) { $rows = $query->result_array(); } else { $this->sys_error_db("nat_advice select"); exit; } $result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows); $this->sys_ok($result); } catch(Exception $exc) { $message = $exc->getMessage(); $this->sys_error($message); } } function getsexreg(){ if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $rows = []; $query =" SELECT * FROM nat_sex WHERE Nat_SexIsActive = 'Y' "; //echo $query; $rows['sexes'] = $this->db_onedev->query($query)->result_array(); $query =" SELECT * FROM nat_normalvaluetype WHERE Nat_NormalValueTypeIsActive = 'Y' "; //echo $query; $rows['normalvaluetypees'] = $this->db_onedev->query($query)->result_array(); $query =" SELECT * FROM nat_flag WHERE Nat_FlagIsActive = 'Y' "; //echo $query; $rows['flages'] = $this->db_onedev->query($query)->result_array(); $query =" SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName "; //echo $query; $rows['ageunites'] = $this->db_onedev->query($query)->result_array(); $query =" SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName "; //echo $query; $rows['minageunites'] = $this->db_onedev->query($query)->result_array(); $query =" SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName "; //echo $query; $rows['maxageunites'] = $this->db_onedev->query($query)->result_array(); $query =" SELECT 0 as Nat_SexID, 'Semua' as Nat_SexName UNION SELECT Nat_SexID, Nat_SexName FROM nat_sex WHERE Nat_SexIsActive = 'Y' "; //echo $query; $rows['f_sexs'] = $this->db_onedev->query($query)->result_array(); $query =" SELECT 0 as Nat_FlagID, 'Semua' as Nat_FlagName UNION SELECT Nat_FlagID, Nat_FlagName FROM nat_flag WHERE Nat_FlagIsActive = 'Y'"; //echo $query; $rows['f_flags'] = $this->db_onedev->query($query)->result_array(); $query =" SELECT 'A' as M_StatusID, 'Semua' as M_StatusName UNION SELECT 'Y' as M_StatusID, 'Terpilih' as M_StatusName UNION SELECT 'N' as M_StatusID, 'Belum Terpilih' as M_StatusName "; //echo $query; $rows['f_statuss'] = $this->db_onedev->query($query)->result_array(); $result = array( "total" => count($rows) , "records" => $rows, ); $this->sys_ok($result); exit; } function getstatus(){ if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $rows = []; $query =" SELECT 'A' as M_StatusID, 'Semua' as M_StatusName UNION SELECT 'Y' as M_StatusID, 'Terpilih' as M_StatusName UNION SELECT 'N' as M_StatusID, 'Belum Terpilih' as M_StatusName "; //echo $query; $rows['f_statuss'] = $this->db_onedev->query($query)->result_array(); $result = array( "total" => count($rows) , "records" => $rows, ); $this->sys_ok($result); exit; } public function addnewadvice() { try { //# cek token valid if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } //# ambil parameter input $prm = $this->sys_input; $abnormalid = $prm['abnormalid']; $adviceina = $prm['adviceina']; $adviceeng = $prm['adviceeng']; $userid = $this->sys_user["M_UserID"]; $sql = "insert into nat_advice( Nat_AdviceIna, Nat_AdviceEng, Nat_AdviceUserID, Nat_AdviceCreated, Nat_AdviceLastUpdated ) values(?,?,?,now(),now())"; $query = $this->db_onedev->query($sql, array( $adviceina, $adviceeng, $userid ) ); if (!$query) { $this->sys_error_db("nat_normalvalue insert",$this->db_onedev); exit; } $last_id = $this->db_onedev->insert_id(); $result = array ("total" => 1, "records" => array("xid" => 0)); $this->sys_ok($result); } catch(Exception $exc) { $message = $exc->getMessage(); $this->sys_error($message); } } public function saveaddeditadvice() { try { //# cek token valid if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } //# ambil parameter input $prm = $this->sys_input; $abnormalid = $prm['abnormalid']; $adviceid = $prm['Nat_AdviceID']; $adviceabnormalid = $prm['Nat_AdviceAbnormalID']; $status = $prm['status']; $userid = $this->sys_user["M_UserID"]; if($status == 'Y'){ $sql = "insert into nat_advice_abnormal( Nat_AdviceAbnormalNat_NormalValueID, Nat_AdviceAbnormalNat_AdviceID, Nat_AdviceAbnormalUserID, Nat_AdviceAbnormalCreated, Nat_AdviceAbnormalLastUpdated ) values(?,?,?,now(),now())"; $query = $this->db_onedev->query($sql, array( $abnormalid, $adviceid, $userid ) ); if (!$query) { $this->sys_error_db("nat_advice_abnormal insert",$this->db_onedev); exit; } $last_id = $this->db_onedev->insert_id(); $result = array ("total" => 1, "records" => array("xid" => 0)); $this->sys_ok($result); }else{ $sql = "UPDATE nat_advice_abnormal SET Nat_AdviceAbnormalIsActive = 'N', Nat_AdviceAbnormalUserID = ?, Nat_AdviceAbnormalCreated = now(), Nat_AdviceAbnormalLastUpdated = now() WHERE Nat_AdviceAbnormalID = ?"; $query = $this->db_onedev->query($sql, array( $userid, $adviceabnormalid ) ); if (!$query) { $this->sys_error_db("nat_advice_abnormal insert",$this->db_onedev); exit; } $last_id = $this->db_onedev->insert_id(); $result = array ("total" => 1, "records" => array("xid" => 0)); $this->sys_ok($result); } } catch(Exception $exc) { $message = $exc->getMessage(); $this->sys_error($message); } } function saveeditsaran(){ if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $prm = $this->sys_input; $userid = $this->sys_user["M_UserID"]; $query = " UPDATE nat_advice SET Nat_AdviceIna = '{$prm['ina']}', Nat_AdviceEng = '{$prm['eng']}', Nat_AdviceIsActive = '{$prm['status']}', Nat_AdviceUserID = {$userid} WHERE Nat_AdviceID = {$prm['id']} "; //echo $query; $action = $this->db_onedev->query($query); if($action){ $result = array( "total" => 1 , "records" => array(), ); $this->sys_ok($result); exit; } else{ $this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev); exit; } } function savealladvice(){ if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $prm = $this->sys_input; $details = $prm['details']; $userid = $this->sys_user["M_UserID"]; foreach($details as $k => $v){ $query = "UPDATE nat_advice_abnormal SET Nat_AdviceAbnormalNat_NormalValueID = '{$v['Nat_AdviceAbnormalNat_NormalValueID']}', Nat_AdviceAbnormalAdviceIna = '{$v['Nat_AdviceAbnormalAdviceIna']}', Nat_AdviceAbnormalAdviceEng = '{$v['Nat_AdviceAbnormalAdviceEng']}', Nat_AdviceAbnormalUserID = {$userid}, Nat_AdviceAbnormalCreated = now(), Nat_AdviceAbnormalLastUpdated = now() WHERE Nat_AdviceAbnormalID = {$v['Nat_AdviceAbnormalID']}"; //echo $query; $action = $this->db_onedev->query($query); } if($action){ $result = array( "total" => 1 , "records" => array(), ); $this->sys_ok($result); exit; } else{ $this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev); exit; } } public function deleteabnormal() { try { //# cek token valid if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } //# ambil parameter input $prm = $this->sys_input; $userid = $this->sys_user["M_UserID"]; $sql = "update nat_methode SET Nat_MethodeIsActive = 'N' WHERE Nat_MethodeID = ? "; $query = $this->db_onedev->query($sql, array( $prm['id'] ) ); // echo $query; if (!$query) { $this->sys_error_db("nat_methode delete"); exit; } $sql = "update nat_normalvalue SET Nat_NormalValueIsActive = 'N' WHERE Nat_NormalValueNat_MethodeID = ? "; $query = $this->db_onedev->query($sql, array( $prm['id'] ) ); // echo $query; if (!$query) { $this->sys_error_db("nat_normalvalue delete"); exit; } $result = array ("total" => 1, "records" => array("xid" => 0)); $this->sys_ok($result); } catch(Exception $exc) { $message = $exc->getMessage(); $this->sys_error($message); } } public function deleteadvice() { try { //# cek token valid if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } //# ambil parameter input $prm = $this->sys_input; $userid = $this->sys_user["M_UserID"]; $sql = "update nat_normalvalue SET Nat_NormalValueIsActive = 'N' WHERE Nat_NormalValueID = ? "; $query = $this->db_onedev->query($sql, array( $prm['id'] ) ); // echo $query; if (!$query) { $this->sys_error_db("nat_normalvalue delete"); exit; } $result = array ("total" => 1, "records" => array("xid" => 0)); $this->sys_ok($result); } catch(Exception $exc) { $message = $exc->getMessage(); $this->sys_error($message); } } function searchabnormal(){ if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $prm = $this->sys_input; $max_rst = 12; $tot_count =0; $q = [ 'search' => '%' ]; if ($prm['search'] != '') { $q['search'] = "%{$prm['search']}%"; } // QUERY TOTAL $sql = "SELECT count(*) as total FROM nat_methode WHERE Nat_MethodeName like ? AND Nat_MethodeIsActive = 'Y'"; $query = $this->db_onedev->query($sql,$q['search']); //echo $query; if ($query) { $tot_count = $query->result_array()[0]["total"]; } else { $this->sys_error_db("nat_methode count",$this->db_onedev); exit; } $sql = " SELECT Nat_MethodeID, Nat_MethodeName FROM nat_methode WHERE Nat_MethodeName like ? AND Nat_MethodeIsActive = 'Y' ORDER BY Nat_MethodeName ASC "; $query = $this->db_onedev->query($sql, array($q['search'])); if ($query) { $rows = $query->result_array(); //echo $this->db_onedev->last_query(); $result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows)); $this->sys_ok($result); } else { $this->sys_error_db("nat_methode rows",$this->db_onedev); exit; } } function searchabnormalbyname(){ if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $prm = $this->sys_input; $max_rst = 12; $tot_count =0; $q = [ 'search' => '%' ]; if ($prm['search'] != '') { $q['search'] = "%{$prm['search']}%"; } // QUERY TOTAL $sql = "SELECT count(*) as total FROM nat_methode WHERE Nat_MethodeName like ? AND Nat_MethodeIsActive = 'Y'"; $query = $this->db_onedev->query($sql,$q['search']); //echo $query; if ($query) { $tot_count = $query->result_array()[0]["total"]; } else { $this->sys_error_db("nat_methode count",$this->db_onedev); exit; } $sql = " SELECT Nat_MethodeID, Nat_MethodeName FROM nat_methode WHERE Nat_MethodeName like ? AND Nat_MethodeIsActive = 'Y' ORDER BY Nat_MethodeName ASC "; $query = $this->db_onedev->query($sql, array($q['search'])); if ($query) { $rows = $query->result_array(); //echo $this->db_onedev->last_query(); $result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows)); $this->sys_ok($result); } else { $this->sys_error_db("nat_methode rows",$this->db_onedev); exit; } } function searchtest(){ if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $prm = $this->sys_input; $max_rst = 12; $tot_count =0; $q = [ 'search' => '%' ]; if ($prm['search'] != '') { $q['search'] = "%{$prm['search']}%"; } // QUERY TOTAL $sql = "SELECT count(*) as total FROM t_test WHERE T_TestName like ? AND T_TestIsActive = 'Y' AND T_TestIsResult = 'Y'"; $query = $this->db_onedev->query($sql,$q['search']); //echo $query; if ($query) { $tot_count = $query->result_array()[0]["total"]; } else { $this->sys_error_db("t_test count",$this->db_onedev); exit; } $sql = " SELECT * FROM t_test WHERE T_TestName like ? AND T_TestIsActive = 'Y' AND T_TestIsResult = 'Y' ORDER BY T_TestName ASC "; $query = $this->db_onedev->query($sql, array($q['search'])); if ($query) { $rows = $query->result_array(); //echo $this->db_onedev->last_query(); $result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows)); $this->sys_ok($result); } else { $this->sys_error_db("t_test rows",$this->db_onedev); exit; } } }