[eluser]JamieBarton[/eluser]
Hi guys,
I'm after a little help on this query I'm trying to run.
I'm having one of those days.
The code below is what I'm having trouble with. I've commented out what I know doesn't work because I know I need to use brackets in this query.
Basically I want to search for rows in the 'users' table WHERE username LIKE $name or name LIKE $name AND exclude myself from the query by saying my 'id' is $user_id.
Code:
public function search_for_users($term) {
//$this->db->like('username', $term);
//$this->db->or_like('name', $term);
//$this->db->where('username !=', current_user()->username);
$user_id = current_user()->id;
$where = "(`username` LIKE $term OR `name` LIKE $term) AND `id` != $user_id";
$this->db->where($where);
return $this->db->get($this->_users_table);
}
Hopefully one of you will be able to help!
Regards,
Jamie