diff --git a/application/libraries/Datatables.php b/application/libraries/Datatables.php index 161cdbc..87f480e 100644 --- a/application/libraries/Datatables.php +++ b/application/libraries/Datatables.php @@ -157,7 +157,7 @@ public function or_where($key_condition, $val = NULL, $backtick_protect = TRUE) $this->ci->db->or_where($key_condition, $val, $backtick_protect); return $this; } - + /** * Generates the WHERE IN portion of the query * @@ -324,13 +324,27 @@ private function get_filtering() $sSearch = $this->ci->db->escape_like_str(trim($search['value'])); $columns = array_values(array_diff($this->columns, $this->unset_columns)); - if($sSearch != '') - for($i = 0; $i < count($mColArray); $i++) - if ($mColArray[$i]['searchable'] == 'true' && !array_key_exists($mColArray[$i]['data'], $this->add_columns)) - if($this->check_cType()) + for($i = 0; $i < count($mColArray); $i++){ + if(!empty($search['value'])){ + $sSearch = $this->ci->db->escape_like_str(trim($search['value'])); + if ($mColArray[$i]['searchable'] == 'true' && !array_key_exists($mColArray[$i]['data'], $this->add_columns)){ + if($this->check_cType()){ $sWhere .= $this->select[$mColArray[$i]['data']] . " LIKE '%" . $sSearch . "%' OR "; - else + }else{ $sWhere .= $this->select[$this->columns[$i]] . " LIKE '%" . $sSearch . "%' OR "; + } + } + } + + if (!empty($mColArray[$i]['search']['value'])){ + $cSearch = $this->ci->db->escape_like_str(trim($mColArray[$i]['search']['value'])); + if($this->check_cType()){ + $sWhere .= $this->select[$mColArray[$i]['data']] . " LIKE '%" . $cSearch . "%' OR "; + }else{ + $sWhere .= $this->select[$this->columns[$i]] . " LIKE '%" . $cSearch . "%' OR "; + } + } + } $sWhere = substr_replace($sWhere, '', -3); @@ -431,7 +445,7 @@ private function get_total_results($filtering = FALSE) foreach($this->or_where as $val) $this->ci->db->or_where($val[0], $val[1], $val[2]); - + foreach($this->where_in as $val) $this->ci->db->where_in($val[0], $val[1]); @@ -467,7 +481,7 @@ private function get_total_results($filtering = FALSE) private function exec_replace($custom_val, $row_data) { $replace_string = ''; - + // Go through our array backwards, else $1 (foo) will replace $11, $12 etc with foo1, foo2 etc $custom_val['replacement'] = array_reverse($custom_val['replacement'], true); @@ -629,7 +643,7 @@ private function jsonify($result = FALSE) return '{' . join(',', $json) . '}'; } } - + /** * returns the sql statement of the last query run * @return type