phpcodeigniterwhere-clausequery-buildermethod-chaining

Call to undefined method CI_DB_mysqli_driver::and()


$q_cat_beauty = $this->db->select('*')->from('ms_categories')->where('source_id', 1)->and('category_name', 'Oral Care')->get();

i am trying to fetch the category name from my table.


Solution

  • There is no and keyword or method in CI. If you want where with and condition you again have to write where

    $q_cat_beauty = $this->db->select('*')->from('ms_categories')
    ->where('source_id', 1)->where('category_name', 'Oral Care')->get();
    

    or use array in where

    $q_cat_beauty = $this->db->select('*')->from('ms_categories')
    ->where(array('source_id'=> 1,'category_name' => 'Oral Care'))->get();