Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flexigrid/bootstrap theme -> WHERE clause AND (search term_n OR search term_n+1...etc.), not OR #414

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 25 additions & 24 deletions application/libraries/Grocery_CRUD.php
Original file line number Diff line number Diff line change
Expand Up @@ -636,31 +636,32 @@ protected function set_ajax_list_queries($state_info = null)
foreach($this->where as $where)
$this->basic_model->having($where[0],$where[1],$where[2]);

foreach($columns as $column)
{
if(isset($temp_relation[$column->field_name]))
{
if(is_array($temp_relation[$column->field_name]))
{
foreach($temp_relation[$column->field_name] as $search_field)
{
$this->or_like($search_field, $search_text);
}
}
else
{
$this->or_like($temp_relation[$column->field_name], $search_text);
}
}
elseif(isset($this->relation_n_n[$column->field_name]))
{
//@todo have a where for the relation_n_n statement
}
elseif (isset($field_types[$column->field_name])
&& !in_array($field_types[$column->field_name]->type, array('date', 'datetime', 'timestamp')))
{
$this->or_like($column->field_name, $search_text);
$likes = array();

foreach ($columns as $column) {
if (isset($temp_relation[$column->field_name])) {
if (is_array($temp_relation[$column->field_name])) {
foreach ($temp_relation[$column->field_name] as $search_field) {
$likes[$search_field] = $search_text;
}
} else {
$likes[$temp_relation[$column->field_name]] = $search_text;
}
} elseif (isset($this->relation_n_n[$column->field_name])) {
//@todo have a where for the relation_n_n statement
} else {
$likes[$column->field_name] = $search_text;
}
}

$where_clause = "";
foreach ($likes as $field => $search_text) {
$where_clause = $where_clause. " OR ".$field. " LIKE '%".$this->basic_model->escape_like_str($search_text)."%' ESCAPE '!'";
}

if(sizeof($likes)>0){
$where_clause = "(".substr($where_clause, 4).")";
$this->basic_model->where($where_clause);
}
}
}
Expand Down