2014-02-18 98 views
1

考慮這個功能笨檢索從DB數據:笨DB where子句語法錯誤

function popular_list($limit=2) 
{ 
    $this->db->select('news.*'); 
    $this->db->where('id',$this->uri->segment(3)); 
    $this->db->where('publish',1); 
    $this->db->where('viewed',(>=5)); 
    $this->db->order_by('id','DESC'); 
    $this->db->limit($limit); 
    $query = $this->db->get('news');  
    return $query->result(); 
} 

我得到這個語法錯誤:

Parse error: parse error in C:\xampp\htdocs\misnews\application\models\home_model.php on line 113 Line 113 is : $this->db->where('viewed',(>=5)); 

我在做什麼錯?

+0

發表您的完整的錯誤文本 –

+0

解析錯誤:解析用C錯誤:\ XAMPP \ htdocs中\ misnews \程序\型號\ home_model.php上線113 線113是:$ this-> db-> where('viewed',(> = 5)); –

+0

@Ramnique:謝謝你的糾正:) –

回答

1

變化的條件如下:

$this->db->where('viewed >= ',5); 
+1

幹得好Kumar。謝謝 –