public function addCondition($field, $operator = null, $value = null)
    {
        if (is_array($field)) {
            $this->conditions[] = [$field];

            return $this;

            /*
            $or = $this->persistence->orExpr();

            foreach ($field as list($field, $operator, $value)) {
                if (is_string($field)) {
                    $f = $this->hasField($field);
                    if (!$f) {
                        throw new Exception([
                            'Field does not exist',
                            'model' => $this,
                            'field' => $field,
                        ]);
                    }
                } elseif ($field instanceof Field) {
                    $f = $field;
                }

                $or->where($f, $operator, $value);
            }

            return $this;
            */
        }

        $f = (is_string($field) || $field instanceof Field) ? $this->getField($field) : false;
        if ($f) {
            if ($operator === '=' || func_num_args() == 2) {
                $v = $operator === '=' ? $value : $operator;

                if (!is_object($v) && !is_array($v)) {
                    $f->system = true;
                    $f->default = $v;
                }
            }
        }

        $this->conditions[] = func_get_args();

        return $this;
    }
public function addCondition($field, $operator = null, $value = null)
    {
        if (is_array($field)) {
            $this->conditions[] = [$field];

            return $this;

            /*
            $or = $this->persistence->orExpr();

            foreach ($field as list($field, $operator, $value)) {
                if (is_string($field)) {
                    $f = $this->hasField($field);
                    if (!$f) {
                        throw new Exception([
                            'Field does not exist',
                            'model' => $this,
                            'field' => $field,
                        ]);
                    }
                } elseif ($field instanceof Field) {
                    $f = $field;
                }

                $or->where($f, $operator, $value);
            }

            return $this;
            */
        }

        $f = (is_string($field) || $field instanceof Field) ? $this->getField($field) : false;
        if ($f) {
            if ($operator === '=' || func_num_args() == 2) {
                $v = $operator === '=' ? $value : $operator;

                if (!is_object($v) && !is_array($v)) {
                    $f->system = true;
                    $f->default = $v;
                }
            }
        }

        $this->conditions[] = func_get_args();

        return $this;
    }
public function addCondition ( $ field , $ operator = null , $ value = null ) { if ( is_array ( $ field ) ) { $ this -> conditions [ ] = [ $ field ] ; return $ this ; /*
            $or = $this->persistence->orExpr();

            foreach ($field as list($field, $operator, $value)) {
                if (is_string($field)) {
                    $f = $this->hasField($field);
                    if (!$f) {
                        throw new Exception([
                            'Field does not exist',
                            'model' => $this,
                            'field' => $field,
                        ]);
                    }
                } elseif ($field instanceof Field) {
                    $f = $field;
                }

                $or->where($f, $operator, $value);
            }

            return $this;
            */ } $ f = ( is_string ( $ field ) || $ field instanceof Field ) ? $ this -> getField ( $ field ) : false ; if ( $ f ) { if ( $ operator === '=' || func_num_args ( ) == 2 ) { $ v = $ operator === '=' ? $ value : $ operator ; if ( ! is_object ( $ v ) && ! is_array ( $ v ) ) { $ f -> system = true ; $ f -> default = $ v ; } } } $ this -> conditions [ ] = func_get_args ( ) ; return $ this ; }
Narrow down data-set of the current model by applying
additional condition. There is no way to remove
condition once added, so if you need - clone model.

This is the most basic for defining condition:
->addCondition('my_field', $value);

This condition will work across all persistence drivers universally.

In some cases a more complex logic can be used:
->addCondition('my_field', '>', $value);
->addCondition('my_field', '!=', $value);
->addCondition('my_field', 'in', [$value1, $value2]);

Second argument could be '=', '>', '<', '>=', '<=', '!=' or 'in'.
Those conditions are still supported by most of persistence drivers.

There are also vendor-specific expression support:
->addCondition('my_field', $expr);
->addCondition($expr);

To use those, you should consult with documentation of your
persistence driver.

@param mixed $field
@param mixed $operator
@param mixed $value

@return $this
Narrow down data - set of the current model by applying additional condition . There is no way to remove condition once added so if you need - clone model .