Hi there,
So I have a module "Contestants" which has the following filters:
public $filters = array('users.email', 'model_search', 'status');
Then I have my list_items like so:
function list_items($limit = NULL, $offset = NULL, $col = 'name', $order = 'asc', $just_count = FALSE)
{
$this->db->join("users", "contestants.user_id = users.id");
$this->db->select('contestants.id, contestants.user_id, CONCAT(users.first_name, " ", users.last_name) as name, users.email', FALSE);
$data = parent::list_items($limit, $offset, $col, $order, $just_count);
return $data;
}
Now this should be working as intended no? A search I would expect to search through email, model_search and status fields. However, searching gives me an mySQL error:
A Database Error Occurred
Error Number: 1054
Unknown column 'contestants.user_name' in 'where clause'
SELECT COUNT(*) AS `numrows` FROM (`contestants`) JOIN `users` ON `contestants`.`user_id` = `users`.`id` WHERE (LOWER(users.email) LIKE "%orla%" OR LOWER(contestants.model_search) LIKE "%orla%" OR LOWER(contestants.status) LIKE "%orla%" OR LOWER(contestants.user_name) LIKE "%orla%")
Where is -- LOWER(contestants.user_name) LIKE "%orla%" -- coming from? o.O
Comments
LOWER(contestants.user_name) LIKE "%orla% is coming from parent::list_items method call which is referring to the Base_module_model::list_items() method which subsequently calls a protected _list_items_query method.
$this->db->select('contestants.id, contestants.user_id, CONCAT(users.first_name, " ", users.last_name) as name, users.email', FALSE);
to
$this->db->select('contestants.id, contestants.user_id, CONCAT(users.first_name, " ", users.last_name) as name, users.email, user.username', FALSE);
is necessary for that to function, however it doesn't change the query at all, how can I overwrite whats coming from the parent list?
unset($this->filters['user_name']