laravel whereraw与声明在哪里

时间:2014-01-09 10:13:44

标签: laravel where where-in

我正在尝试使用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);

1 个答案:

答案 0 :(得分:2)

为什么不使用where和whereIn`方法?

return $this->object->where('status', '=', $active)->whereIn('salesType', $array);