當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Builder::whereNested方法代碼示例

本文整理匯總了PHP中Illuminate\Database\Query\Builder::whereNested方法的典型用法代碼示例。如果您正苦於以下問題:PHP Builder::whereNested方法的具體用法?PHP Builder::whereNested怎麽用?PHP Builder::whereNested使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Database\Query\Builder的用法示例。


在下文中一共展示了Builder::whereNested方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: applyFilterConstraint

 /**
  * {@inheritdoc}
  */
 public function applyFilterConstraint(Builder $query, $data)
 {
     if ($this->multiple or !($data = $this->parse($data))) {
         return;
     }
     $query->whereNested(function ($inner) use($data) {
         foreach ($data as $key) {
             $inner->orWhere($this->id, '=', $key);
         }
     });
 }
開發者ID:guratr,項目名稱:cruddy,代碼行數:14,代碼來源:Enum.php

示例2: apply

 /**
  * @param \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder $query
  *
  * @return void
  */
 public function apply($query)
 {
     $query->where(function ($query) {
         $logic = $this->logic === static::LOGIC_AND ? 'and' : 'or';
         foreach ($this->criteria as $criteria) {
             $query->whereNested(function ($query) use($criteria) {
                 $criteria->apply($query);
             }, $logic);
         }
     });
 }
開發者ID:viniciusferreira,項目名稱:laravel-repository,代碼行數:16,代碼來源:MultipleCriteria.php

示例3: buildWheres

 /**
  * @param Builder|QueryBuilder $queryBuilder
  * @param array $wheres
  * @param string $boolean
  */
 protected function buildWheres($queryBuilder, array $wheres, $boolean = 'and')
 {
     foreach ($wheres as $whereField => $where) {
         if (!isset($whereField) || !isset($where)) {
             continue;
         }
         $whereField = strtolower($whereField);
         // Nested OR where
         // Example: 'or' => ['foo' => 'bar', 'x => 'y']
         if ($whereField === 'or') {
             $queryBuilder->whereNested(function ($queryBuilder) use($where) {
                 $this->buildWheres($queryBuilder, $where, 'or');
             }, $boolean);
             continue;
         }
         // Nested AND where
         // Example: 'and' => ['foo' => 'bar', 'x => 'y']
         if ($whereField === 'and') {
             $queryBuilder->whereNested(function ($queryBuilder) use($where) {
                 $this->buildWheres($queryBuilder, $where, 'and');
             }, $boolean);
             continue;
         }
         // Operator is present on query
         // Example: 'foo' => ['like' => '%bar%']
         if (is_array($where)) {
             foreach ($where as $whereOperator => $whereValue) {
                 $whereOperator = $this->parseOperator($whereOperator);
                 $this->buildWhere($queryBuilder, $whereField, $whereOperator, $whereValue, $boolean);
             }
             continue;
         }
         // Operator is omitted on query, assumes '='
         // Example: 'foo' => 'bar'
         $whereOperator = is_array($where) ? array_keys($where)[0] : '=';
         $whereValue = is_array($where) ? $where[$whereOperator] : $where;
         $whereOperator = $this->parseOperator($whereOperator);
         $this->buildWhere($queryBuilder, $whereField, $whereOperator, $whereValue, $boolean);
     }
 }
開發者ID:williamoliveira,項目名稱:eloquent-array-query-builder,代碼行數:45,代碼來源:ArrayBuilder.php

示例4: whereNested

 /**
  * Add a nested where statement to the query.
  *
  * @param \Closure $callback
  * @param string $boolean
  * @return \Illuminate\Database\Query\Builder|static 
  * @static 
  */
 public static function whereNested($callback, $boolean = 'and')
 {
     return \Illuminate\Database\Query\Builder::whereNested($callback, $boolean);
 }
開發者ID:satriashp,項目名稱:tour,代碼行數:12,代碼來源:_ide_helper.php

示例5: applyKeywordsFilter

 /**
  * Filter by keywords.
  *
  * @param \Illuminate\Database\Query\Builder $builder
  * @param array $keywords
  *
  * @return void
  */
 protected function applyKeywordsFilter(QueryBuilder $builder, array $keywords)
 {
     $builder->whereNested(function ($q) use($keywords) {
         /**
          * @var KeywordsFilter $item
          */
         foreach ($this->items as $item) {
             if ($item instanceof KeywordsFilter) {
                 $item->applyKeywordsFilter($q, $keywords);
             }
         }
     });
 }
開發者ID:guratr,項目名稱:cruddy,代碼行數:21,代碼來源:Collection.php

示例6: createNestedQuery

 /**
  * Create nested queries
  *
  * When a rule is actually a group of rules, we want to build a nested query, and set the consition to be the
  * specified condition (AND/OR) within this new set of rules
  *
  * @param Builder $querybuilder
  * @param stdClass $rule
  * @param String $condition
  * @return mixed
  */
 protected function createNestedQuery(Builder $querybuilder, stdClass $rule, $condition)
 {
     $subCondition = $this->validateCondition($rule->condition);
     return $querybuilder->whereNested(function ($query) use(&$rule, &$querybuilder, &$subCondition) {
         foreach ($rule->rules as $_rule) {
             if ($this->isNested($_rule)) {
                 $querybuilder = $this->createNestedQuery($query, $_rule, $subCondition);
             } else {
                 $querybuilder = $this->makeQuery($query, $_rule, $subCondition);
             }
         }
     }, $condition);
 }
開發者ID:simplesi,項目名稱:QueryBuilderParser,代碼行數:24,代碼來源:QueryBuilderParser.php


注:本文中的Illuminate\Database\Query\Builder::whereNested方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。