Hi. I've had a big problem with this stuff. When i have a relation column in flexigrid, and i try to search any word dont work, mysql error:
Error Number: 1052</p><p>Column 'name' in where clause is ambiguous</p><p>
/topic/921-ajax-list-info-ambiguous-field-in-search/
I made a solution for this for the last version 1.5
Sorry for my bad english.
All you need to do is follow the next steps or download the php files
STEP 1) Grocery_crud_model.php, function get_list:
Replace //>>>> HERE <<<< string and paste this code and comment the next line:
$query = $this->db->get_compiled_select($this->table_name, TRUE); foreach($this->relation as $rel) { $table = $rel[1]; $query = str_replace('table_unique__' . $table . '__', constant('gc_table_unique_' . $table), $query); //INTRUSIVO } $results = $this->db->query($query)->result();
Result:
STEP 2) Grocery_crud_model.php, function get_total_results:
Replace //>>>> HERE <<<< string and paste this code
$query = $this->db->get_compiled_select($this->table_name, TRUE); foreach($this->relation as $rel) { $table = $rel[1]; $query = str_replace('table_unique__' . $table . '__', constant('gc_table_unique_' . $table), $query); //INTRUSIVO } return $this->db->query($query)->num_rows;
Result:
STEP 3) Grocery_crud_model.php, function join_relation:
Replace //>>>> HERE <<<< string and paste this code
define("gc_table_unique_" . $related_table, $unique_name);
Result:
STEP 4) Grocery_CRUD.php, function set_ajax_list_queries:
Replace the red selection with the next code:
$field_names = $this->_get_field_names_to_search($relation_values); if(is_array($field_names)) { $field_names[] = $relation_values[1]; } $temp_relation[$this->_unique_field_name($relation_name)] = $field_names;
STEP 5) Grocery_CRUD.php, function set_ajax_list_queries:
Replace the red selection with the next code:
$temp_relation_arr = $temp_relation[$column->field_name]; $last_key = count($temp_relation_arr) - 1; $table = $temp_relation_arr[$last_key]; unset($temp_relation_arr[$last_key]); foreach($temp_relation_arr as $search_field) { $this->or_like('table_unique__' . $table . '__.' . $search_field, $search_text); }
STEP 6) Grocery_CRUD.php, function set_ajax_list_queries:
Replace the red selection with the next code:
$this->or_like($this->basic_db_table . '.' . $column->field_name, $search_text);
END
Sorry again for my bad english
Enjoy!