I'm working on CI3 project and I'm trying to create a search in datatables all works well when I'm using this code:
function getDataUserByFilter($rowno, $rowperpage, $keyword = null, $operator = '', $orderBy = '', $sortingBy = '', $filter_data_by_page = '')
{
$selectQuery = 'select a.id, a.phone, a.email, a.create_date , a.name, a.status, a.online, a.kuota_task,a.wallet from users a';
if ($operator != '') {
$selectQuery = $selectQuery . ' inner join telco_prefix on
substring(a.phone, 1, 4) =
telco_prefix.prefix and telco_prefix.telco_id = \'' . $operator . '\'';
}
if ($keyword != null) {
$selectQuery = $selectQuery .
' where a.phone like \'%' . $keyword . '%\'
or a.email like \'%' . $keyword . '%\'
or a.name like \'%' . $keyword . '%\'
or CAST(a.kuota_task AS text) like \'%' . $keyword . '% \'
or CAST(a.wallet AS text) like \'%' . $keyword . '% \'
or CAST(a.create_date AS text) like \'%' . $keyword . '% \'';
}
if ($filter_data_by_page == 'online') {
if ($keyword != null) {
$selectQuery = $selectQuery . ' a.online = 1';
} else {
$selectQuery = $selectQuery . ' where a.online = 1';
}
}
$query = $this->db->query($selectQuery . ' order by ' . $orderBy . ' ' . $sortingBy . ' limit \'' . $rowperpage . '\' offset \'' . $rowno . '\'')->result_array();
return $query;
but only one problem, that it can only search email, name and phone. Other than that it doesn't work. Like if I try to search the kuota_task or wallet or create_date the search not working. Can anyone please tell me what is wrong with the code or help me to find the solution?