I am trying to run the sql query using codeigniter
but unable to get success due to single quotes in the query. Following is my query:
function getStaffUser($uid, $participant_list=0) {
$rid='1,2,3';
$where = "FIND_IN_SET(users.role_id, '".$rid."')";
$where_plist = "NOT FIND_IN_SET(users.uid, '".$participant_list."')";
$this->db->select("users.uid, CONCAT(`users`.`given_name`, ' ',`users`.`surname`) as 'user_name'", false);
$this->db->from('users');
$this->db->where($where);
$this->db->where("users.uid!=", $uid, false);
if($participant_list!=0){
$this->db->where($where_plist, false);
}
$data = $this->db->get();
pr($this->db->last_query()); exit;
if ($data->num_rows() == 0)
return false;
else
return $data->result();
}
It returns the following query:
SELECT users.uid, CONCAT(`users`.`given_name`, ' ', `users`.`surname`) as 'user_name' FROM (`users`) WHERE FIND_IN_SET(users.role_id, '1,2,3') AND users.uid!=1 AND `NOT` FIND_IN_SET(users.uid, '1,18,60')
However, the query is all fine except the single quotes only on 'NOT'
in the last. If if remove that single quotes and run in the sqlyog
it works fine.
Therefore, what is the best way to remove it. I tried to use false
but it did not work either.
ANy help ?
Thanks.