2017-06-07 06:16 阅读 295

调用未定义的方法CI_DB_mysqli_driver ::和()

$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.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    dongpu1315 dongpu1315 2017-06-07 06:18

    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();
    点赞 评论 复制链接分享
  • dongzhang3482 dongzhang3482 2017-06-07 06:19

    Try This

     $q_cat_beauty =
     $this->db->where('source_id', 1)
    ->where('category_name', 'Oral Care')

    The Query builder class dosnt support and() so if you chain 2 where together like above it will represent the and you can keep chaining

    点赞 评论 复制链接分享