我正在尝试使用whereRaw在查询构建器中使用WHERE IN语句,但它似乎不起作用。我不是试图从其他表中选择值,只是从多个值中选择。
我尝试过这三种方法:
return $this->object->whereRaw("`status` = 'active' AND `salesType` IN ( ? ) AND `region_id` = ?", array("'sale','buy'","1"))->paginate(10);
return $this->object->whereRaw("`status` = 'active' AND `salesType` IN ( ? ) AND `region_id` = ?", array("sale,buy","1"))->paginate(10);
return $this->object->whereRaw("`status` = 'active' AND `salesType` IN ( ? ) AND `region_id` = ?", array(array("sale,buy"),"1"))->paginate(10);
答案 0 :(得分:2)
为什么不使用where
和whereIn`方法?
return $this->object->where('status', '=', $active)->whereIn('salesType', $array);