1
我在我的模型中使用了以下函数来搜索短语等。但是,如果我传入多个单词,则空格总是会转换为打破我的查询的%20符号。我如何避免这种情况?防止查询中的空白转换为%20
默认情况下codeigniter中的这种类型的查询是否安全?还是我需要首先逃避$ term?
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;
}
转义'term'。它不会伤害。 – 2013-02-20 00:34:38