Illuminate\Database\Query\Builder::whereColumn PHP Method

whereColumn() public method

Add a "where" clause comparing two columns to the query.
public whereColumn ( string | array $first, string | null $operator = null, string | null $second = null, string | null $boolean = 'and' ) : Builder | static
$first string | array
$operator string | null
$second string | null
$boolean string | null
return 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;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * 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 
  * @static 
  */
 public static function whereColumn($first, $operator = null, $second = null, $boolean = 'and')
 {
     return \Illuminate\Database\Query\Builder::whereColumn($first, $operator, $second, $boolean);
 }