php - Remove single quotes from sql query -
i trying run sql query using codeigniter
unable success due single quotes in query. following 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`) '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 following query:
select users.uid, concat(`users`.`given_name`, ' ', `users`.`surname`) 'user_name' (`users`) find_in_set(users.role_id, '1,2,3') , users.uid!=1 , `not` find_in_set(users.uid, '1,18,60')
however, query fine except single quotes on 'not'
in last. if if remove single quotes , run in sqlyog
works fine.
therefore, best way remove it. tried use false
did not work either.
any ?
thanks.
you should able use !
, this:
$where_plist = "! find_in_set(users.uid, '".$participant_list."')";
not
, !
aliases: http://dev.mysql.com/doc/refman/5.1/en/logical-operators.html#operator_not
Comments
Post a Comment