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


PHP Grammar::getOperators方法代碼示例

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


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

示例1: where

 /**
  * Add a basic where clause to the query.
  *
  * @param  string|array|\Closure  $column
  * @param  string  $operator
  * @param  mixed   $value
  * @param  string  $boolean
  * @return $this
  *
  * @throws \InvalidArgumentException
  */
 public function where($column, $operator = null, $value = null, $boolean = 'and')
 {
     // If the column is an array, we will assume it is an array of key-value pairs
     // and can add them each as a where clause. We will maintain the boolean we
     // received when the method was called and pass it into the nested where.
     if (is_array($column)) {
         return $this->addArrayOfWheres($column, $boolean);
     }
     // Here we will make some assumptions about the operator. If only 2 values are
     // passed to the method, we will assume that the operator is an equals sign
     // and keep going. Otherwise, we'll require the operator to be passed in.
     if (func_num_args() == 2) {
         list($value, $operator) = [$operator, '='];
     } elseif ($this->invalidOperatorAndValue($operator, $value)) {
         throw new InvalidArgumentException('Illegal operator and value combination.');
     }
     // If the columns is actually a Closure instance, we will assume the developer
     // wants to begin a nested where statement which is wrapped in parenthesis.
     // We'll add that Closure to the query then return back out immediately.
     if ($column instanceof Closure) {
         return $this->whereNested($column, $boolean);
     }
     // If the given operator is not found in the list of valid operators we will
     // assume that the developer is just short-cutting the '=' operators and
     // we will set the operators to '=' and set the values appropriately.
     if (!in_array(strtolower($operator), $this->operators, true) && !in_array(strtolower($operator), $this->grammar->getOperators(), true)) {
         list($value, $operator) = [$operator, '='];
     }
     // If the value is a Closure, it means the developer is performing an entire
     // sub-select within the query and we will need to compile the sub-select
     // within the where clause to get the appropriate query record results.
     if ($value instanceof Closure) {
         return $this->whereSub($column, $operator, $value, $boolean);
     }
     // If the value is "null", we will just assume the developer wants to add a
     // where null clause to the query. So, we will allow a short-cut here to
     // that method for convenience so the developer doesn't have to check.
     if (is_null($value)) {
         return $this->whereNull($column, $boolean, $operator != '=');
     }
     // Now that we are working with just a simple query we can put the elements
     // in our array and add the query binding to our array of bindings that
     // will be bound to each SQL statements when it is finally executed.
     $type = 'Basic';
     $this->wheres[] = compact('type', 'column', 'operator', 'value', 'boolean');
     if (!$value instanceof Expression) {
         $this->addBinding($value, 'where');
     }
     return $this;
 }
開發者ID:hakoncms,項目名稱:hakoncms,代碼行數:61,代碼來源:Builder.php

示例2: whereColumn

 /**
  * Add a "where" clause comparing two columns to the query.
  *
  * @param  string|array  $first
  * @param  string|null  $operator
  * @param  string|null  $second
  * @param  string|null  $boolean
  * @return \Illuminate\Database\Query\Builder|static
  */
 public function whereColumn($first, $operator = null, $second = null, $boolean = 'and')
 {
     // If the column is an array, we will assume it is an array of key-value pairs
     // and can add them each as a where clause. We will maintain the boolean we
     // received when the method was called and pass it into the nested where.
     if (is_array($first)) {
         return $this->addArrayOfWheres($first, $boolean, 'whereColumn');
     }
     // If the given operator is not found in the list of valid operators we will
     // assume that the developer is just short-cutting the '=' operators and
     // we will set the operators to '=' and set the values appropriately.
     if (!in_array(strtolower($operator), $this->operators, true) && !in_array(strtolower($operator), $this->grammar->getOperators(), true)) {
         list($second, $operator) = [$operator, '='];
     }
     $type = 'Column';
     $this->wheres[] = compact('type', 'first', 'operator', 'second', 'boolean');
     return $this;
 }
開發者ID:teckwei1993,項目名稱:laravel-in-directadmin,代碼行數:27,代碼來源:Builder.php


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