Laravel whereIn OR whereIn(Laravel whereIn 或 whereIn)
                            本文介绍了Laravel whereIn 或 whereIn的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
                        
                        问题描述
我正在按过滤器搜索产品:
I'm making a products search by filters:
我的代码:
->where(function($query) use($filter)
{
  if(!empty($filter)){
    foreach ($filter as $key => $value) {           
      $f = explode(",", $value);        
      $query-> whereIn('products.value', $f);
    }           
  }
})
查询:
and (products.value in (Bomann, PHILIPS) and products.value in (red,white)) 
但我需要:
and (products.value in (Bomann, PHILIPS) OR products.value in (red,white)) 
在 Laravel 中是否有类似的东西:
Is there something similar in Laravel:
orWhereIn
推荐答案
您可以只在核心中搜索 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 IlluminateDatabaseQueryBuilder|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.
这篇关于Laravel whereIn 或 whereIn的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
				 沃梦达教程
				
			本文标题为:Laravel whereIn 或 whereIn
				
        
 
            
        
             猜你喜欢
        
	     - PHP Count 布尔数组中真值的数量 2021-01-01
 - 正确分离 PHP 中的逻辑/样式 2021-01-01
 - Mod使用GET变量将子域重写为PHP 2021-01-01
 - 从 PHP 中的输入表单获取日期 2022-01-01
 - Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
 - Laravel 仓库 2022-01-01
 - 带有通配符的 Laravel 验证器 2021-01-01
 - SoapClient 设置自定义 HTTP Header 2021-01-01
 - 如何定位 php.ini 文件 (xampp) 2022-01-01
 - 没有作曲家的 PSR4 自动加载 2022-01-01
 
				
				
				
				