phpcodeigniter

how can i use multiple where clause In codeigniter?


For my database query I have to use multiple where clause query in Codeigniter PHP. I wrote the code like this:

 $this->db->and_where_in('category_name,publication_status','home_headline_sub',1);

But this query shows database query error in browser. Then I wrote this query:

$this->db->where('category_name,publication_status','home_headline_sub',1);

But it still give error. How can I solve this?


Solution

  • You can chain database clauses, so you would write it as

    $this->db->where('category_name','case')->where('publication_status','case')->where('home_headline_sub','case');
    

    This would generate a query's WHERE clause as

    // WHERE category_name = 'case' AND publication_status = 'case' AND home_headline_sub = 'case'
    

    Documentation here: http://ellislab.com/codeigniter/user-guide/database/active_record.html#chaining