Laravel whereIn OR whereIn
You could have searched just for whereIn
function in the core to see that. Here you are. This must answer all your questions
/** * Add a "where in" clause to the query. * * @param string $column * @param mixed $values * @param string $boolean * @param bool $not * @return \Illuminate\Database\Query\Builder|static */public function whereIn($column, $values, $boolean = 'and', $not = false){ $type = $not ? 'NotIn' : 'In'; // If the value of the where in clause is actually a Closure, we will assume that // the developer is using a full sub-select for this "in" statement, and will // execute those Closures, then we can re-construct the entire sub-selects. if ($values instanceof Closure) { return $this->whereInSub($column, $values, $boolean, $not); } $this->wheres[] = compact('type', 'column', 'values', 'boolean'); $this->bindings = array_merge($this->bindings, $values); return $this;}
Look that it has a third boolean param. Good luck.
You have a orWhereIn
function in Laravel. It takes the same parameters as the whereIn
function.
It's not in the documentation but you can find it in the laravel API.http://laravel.com/api/4.1/
That should give you this:
$query-> orWhereIn('products.value', $f);
$query = DB::table('dms_stakeholder_permissions');$query->select(DB::raw('group_concat(dms_stakeholder_permissions.fid) as fid'),'dms_stakeholder_permissions.rights');$query->where('dms_stakeholder_permissions.stakeholder_id','4');$query->orWhere(function($subquery) use ($stakeholderId){ $subquery->where('dms_stakeholder_permissions.stakeholder_id',$stakeholderId); $subquery->whereIn('dms_stakeholder_permissions.rights',array('1','2','3')); }); $result = $query->get();return $result;
// OUTPUT @input $stakeholderId = 1
//select group_concat(dms_stakeholder_permissions.fid) as fid, dms_stakeholder_permissionss
.rights
from dms_stakeholder_permissions
where dms_stakeholder_permissions
.stakeholder_id
= 4 or (dms_stakeholder_permissions
.stakeholder_id
= 1 and dms_stakeholder_permissions
.rights
in (1, 2, 3))