Prevent white space in query being converted to %20

自作多情 提交于 2019-12-06 12:27:02

问题


I have the following function in my model that I want to use to search for phrases and so on. However if I pass in more than one word the spaces are always converted to the %20 symbol which breaks my query. How do I avoid this?

Also is this type of query secure by default in codeigniter? or do I need to escape $term first?

function get_search_entries($limit, $start, $term)
 {

    $this->db->select('statuses.id, title, status, posted_by, created, rating, name');
    $this->db->from('statuses');
    $this->db->join('categories', 'categories.id = statuses.category_id');

    $this->db->where('MATCH (title, status) AGAINST ("'.$term.'")', NULL, FALSE);
    $this->db->limit($limit, $start);
    $query = $this->db->get(); 

    if ($query->num_rows() > 0) {

        return $query->result();   
    }

    return false;      
  }  

回答1:


Use rawurldecode() on your input strings.



来源:https://stackoverflow.com/questions/14970212/prevent-white-space-in-query-being-converted-to-20

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!