Laravel 5查询构建器,复杂的连接(条件AND(条件OR条件))

时间:2018-05-02 22:33:57

标签: php laravel laravel-5 eloquent laravel-query-builder

我需要在Laravel的查询构建器中重现以下查询:

select * from table LEFT JOIN table_b ON `condition` AND (`condition` OR `condition`)

我知道你可以做这样复杂的where语句:

Model::where(function ($query) {
  return $query->where("field","value")->orWhere("field","value");
})->where("field","value")->get();

我知道你可以做这样的半复杂on陈述:

->leftJoin('table', function ($join) {
  $join->on("field","=","field_b")
    ->on("field_a","=","field_c");
})

但我需要condition AND (condition OR condition) INSIDE on声明。这可能在没有DB::raw()或同等的情况下实现吗?

1 个答案:

答案 0 :(得分:1)

使用此:

     for e in S_li: #going through initial list, all elements available
         if e.isdigit() != True: # if it is an integer, create another list within poss 
             poss.extend(e) #if it is a letter add to the same list in poss.