In the project in which I fixed errors, was used grocery_CRUD () plugin. The documentation has an example of using the where clause as below:
$crud = new grocery_CRUD();
$crud->set_language($this->config->item('language'));
$crud->set_table('users_products');
$crud->where('users_products.users_id !=', 1);
The table does not contain records that do not meet the conditions. It looks like everything is ok. Unfortunately, when the user uses the filters placed under the plugin, records that do not meet the condition are also included in the search results.
What am I doing wrong? How do I add search terms?
Ok, I found a solution to the problem. Maybe it is not perfect and probably needs some refactoring but everyone I think will understand the principle of this solution:
In /application/models/Grocery_crud_model.php we must to add two functions:
In /application/libraries/Grocery_CRUD.php we add:
In the same file we add loop to create whereFix conditions and closure for another types of terms by group_start() and group_end(). In fact we can replace functions get_list() and get_total_results():
I hope this piece of code will be useful for someone.