db_smartone = $this->load->database("onedev", true); } public function search() { $prm = $this->sys_input; $qry = "%" . $prm["qry"] . '%'; $sql = "Select M_CompanyID, M_CompanyName, '' as mous from m_company where M_CompanyName like ? and M_CompanyIsActive = 'Y' limit 0,30"; $query = $this->db_smartone->query($sql, array($qry) ); if ($query) { $rows = $query->result_array(); foreach($rows as $k => $v){ $mous= []; $sql = "Select * FROM m_mou WHERE M_MouM_CompanyID = {$v['M_CompanyID']} AND M_MouIsActive = 'Y' "; $mous = $this->db_smartone->query($sql)->result_array(); $rows[$k]['mous'] = $mous; $rows[$k]['mous'][] = array("M_MouID" => 0, "M_MouName" => "Semua","M_MouStartDate" => '',"M_MouEndDate" => ''); } $rows[] = array("M_CompanyID" => 0, "M_CompanyName" => "Semua","mous" => array()); $result = array("data" => $rows ); $this->sys_ok($result); } else { $this->sys_error_db("", $this->db_smartone); exit; } } }