public function addCondition($field, $value = false, $operator = '=')
    {
        if (is_array($field) && !$value) {
            foreach ($field as $key => $value) {
                // handles #6
                if (is_array($value)) {
                    call_user_func_array([$this, 'addCondition'], $value);
                // handles #7
                } elseif (!is_numeric($key)) {
                    $this->addCondition($key, $value);
                // handles #8
                } else {
                    $this->addCondition($value);
                }
            }

            return $this;
        }

        // handles #4 and #5
        $condition = [$field];

        // handles #1, #2, and #3
        if (func_num_args() >= 2) {
            $condition[] = $operator;
            $condition[] = $value;
        }

        $this->conditions[] = $condition;

        return $this;
    }
public function addCondition($field, $value = false, $operator = '=')
    {
        if (is_array($field) && !$value) {
            foreach ($field as $key => $value) {
                // handles #6
                if (is_array($value)) {
                    call_user_func_array([$this, 'addCondition'], $value);
                // handles #7
                } elseif (!is_numeric($key)) {
                    $this->addCondition($key, $value);
                // handles #8
                } else {
                    $this->addCondition($value);
                }
            }

            return $this;
        }

        // handles #4 and #5
        $condition = [$field];

        // handles #1, #2, and #3
        if (func_num_args() >= 2) {
            $condition[] = $operator;
            $condition[] = $value;
        }

        $this->conditions[] = $condition;

        return $this;
    }
public function addCondition ( $ field , $ value = false , $ operator = '=' ) { if ( is_array ( $ field ) && ! $ value ) { foreach ( $ field as $ key => $ value ) { // handles #6 if ( is_array ( $ value ) ) { call_user_func_array ( [ $ this , 'addCondition' ] , $ value ) ; // handles #7 } elseif ( ! is_numeric ( $ key ) ) { $ this -> addCondition ( $ key , $ value ) ; // handles #8 } else { $ this -> addCondition ( $ value ) ; } } return $ this ; } // handles #4 and #5 $ condition = [ $ field ] ; // handles #1, #2, and #3 if ( func_num_args ( ) >= 2 ) { $ condition [ ] = $ operator ; $ condition [ ] = $ value ; } $ this -> conditions [ ] = $ condition ; return $ this ; }
Adds a condition to the statement.

Accepts the following forms:
1. Equality comparison:
addCondition('username', 'john')
2. Comparison with custom operator:
addCondition('balance', 100, '>')
3. IN statement:
addCondition('group', ['admin', 'owner'])
4. SQL fragment:
addCondition('name LIKE "%john%"')
5. Subquery:
addCondition(function(SelectQuery $query) {})
6. List of conditions to add:
addCondition([['balance', 100, '>'],
['user_id', 5]])
7. Map of equality comparisons:
addCondition(['username' => 'john',
'user_id' => 5])
8. List of SQL fragments:
addCondition(['first_name LIKE "%john%"',
'last_name LIKE "%doe%"'])

@param array|string $field
@param string|bool  $value    condition value (optional)
@param string       $operator operator (optional)

@return self
Adds a condition to the statement .