MATCH()反对没有结果

时间:2014-02-14 01:36:33

标签: php mysql codeigniter

我在我的网站上有这两个搜索业务的功能。用户键入名称,它应返回业务。但由于我是MATCH(名字)反对,不知何故它不会起作用。当我使用LIKE时它工作正常。但问题是它必须100%匹配。

EX:如果商家名称为Nova Audio Studio,并且用户键入nova,则使用LIKE将不会执行此操作。我甚至尝试添加 IN BOOLEAN MODE 仍然是相同的。

public function search_result_count($search)
{
    $count=0;
    $search = addslashes($search);
    $city_id = $this->tank_auth->get_user_city()->id;
    $sql="select count(id) as count from ".$this->table_name." where match(name) 
            against ('$search')>0 and city_id ='$city_id'";
    $query=$this->db->query($sql);
    if($row=$query->row())
    {
        $count=$row->count;
    }
    return $count;
}

public function search($search,$limit=10,$offset=0)
{
    $list = array();
    $search = addslashes($search);
    $city_id = $this->tank_auth->get_user_city()->id;
    $sql="select biz.*,
            count( distinct photo.id) as photo_count,
            IF(count( distinct photo.id) > 0, sum(rating)/count( 
           distinct photo.id), sum(rating)) as rating_sum,
            count(distinct review.id) as review_num
    from ".$this->table_name." 
    left join review on biz.id = review.bizid
    left join photo on biz.id = photo.bizid
    where match(biz.name) against ('$search')>0 and biz.city_id ='$city_id' 
    group by biz.id
    limit $offset,$limit";
    $query = $this->db->query($sql);

    foreach($query->result() as $biz)
    {
        if($biz->review_num > 0)
        {
            $biz->rating = (($biz->rating_sum/($biz- 
              >review_num*5))*100).'%';
        }
        else
        {
            $biz->rating = '0%';

        }
        $biz = biz_cat_info($biz);
        $biz->first_photo = $this->get_cover_photo($biz->id);
        $list[] = $biz;
    }
    return $list;

   }

       } 

由于

0 个答案:

没有答案