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


PHP Builder::whereNotIn方法代碼示例

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


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

示例1: metaQueryClause

 /**
  * @param  array   $queries  {
  *
  * @type string    $relation Optional. The MySQL keyword used to join the clauses of the query. Accepts 'AND', Or
  *       'OR'. Default 'AND'.
  *
  * @type array {
  * @type string    $key      Meta key to filter by.
  * @type string    $value    Meta value to filter by.
  * @type string    $compare  MySQL operator used for comparing the $value. Accepts '=',
  *                               '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN',
  *                               'BETWEEN', 'NOT BETWEEN', 'REGEXP', 'NOT REGEXP', or 'RLIKE'.
  *                               Default is '='
  *             }
  * }
  *
  * @param  Builder $q
  * @param  int     $depth
  */
 public function metaQueryClause($queries, &$q, $depth = 0)
 {
     $i = 0;
     foreach ($queries as $key => $query) {
         if ('relation' === $key) {
             //if relation were found we shall skip to the next iteration
             continue;
         } else {
             if (isset($query['key'])) {
                 // That happens when a non-nested query found on the first iteration
                 // in that case we the clause should be AND
                 $relation = 0 === $i ? 'AND' : $queries['relation'];
                 $q->where(function ($q) use($query) {
                     if (isset($query['key'])) {
                         $q->where('meta_key', '=', $query['key']);
                     }
                     if (isset($query['value'])) {
                         if (isset($query['compare'])) {
                             switch (strtolower($query['compare'])) {
                                 case 'between':
                                     $q->whereBetween('meta_value', $query['value']);
                                     break;
                                 case 'not between':
                                     $q->whereNotBetween('meta_value', $query['value']);
                                     break;
                                 case 'in':
                                     $q->whereIn('meta_value', $query['value']);
                                     break;
                                 case 'not in':
                                     $q->whereNotIn('meta_value', $query['value']);
                                     break;
                                 case 'is null':
                                     $q->whereIsNull('meta_value');
                                     break;
                                 case 'is not null':
                                     $q->whereIsNotNull('meta_value');
                                     break;
                                 default:
                                     $q->where('meta_value', $query['compare'], $query['value']);
                             }
                         } else {
                             $q->where('meta_value', '=', $query['value']);
                         }
                     }
                 }, null, null, $relation);
             } else {
                 if (is_array($query)) {
                     $depth = $depth + 1;
                     // If we're going recursive for the first iterate we shall make the relation AND by default
                     // else we should use the provided relation
                     $relation = 1 === $depth && 0 === $i ? 'AND' : $queries['relation'];
                     $q->where(function ($q) use($query, $depth) {
                         $this->metaQueryClause($query, $q, $depth);
                     }, null, null, $relation);
                 } else {
                     continue;
                 }
             }
         }
         $i++;
     }
 }
開發者ID:puresolcom,項目名稱:polyether,代碼行數:81,代碼來源:MetaQuery.php

示例2: scopeExceptIds

 /**
  * Exclude IDs from query
  * @param  Builder $query
  * @param  array  $ids
  * @return void
  */
 public function scopeExceptIds($query, array $ids)
 {
     $query->whereNotIn($this->getKeyName(), $ids);
 }
開發者ID:ruysu,項目名稱:laravel-core,代碼行數:10,代碼來源:Model.php


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