Oryza Sativae
Oryza Sativae

Reputation: 99

Codeigniter DB where clause syntax error

Consider this function to retrieve data from DB in Codeigniter:

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();
}

I'm getting this parse error:

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));

What am I doing wrong?

Upvotes: 1

Views: 112

Answers (1)

Kumar V
Kumar V

Reputation: 8840

change your condition as below:

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

Upvotes: 1

Related Questions