src/Colorium/Orm/Mapper/Query.php
public function where($expression, $value = null)
    {
        // shortcut : id
        if(is_int($expression) and !$value) {
            $expression = ['id' => $expression];
        }
        // force array
        elseif(!is_array($expression)) {
            $expression = [$expression => $value];
        }

        // parse each expression
        foreach($expression as $condition => $input) {

            // parse condition
            if(!preg_match('/^(?P<field>[a-zA-Z_0-9]+)( (?P<operator>.+))?$/', $condition, $extract)) {
                throw new \PDOException('Invalid expression "' . $condition . '"');
            }

            // clean condition
            $field = trim($extract['field']);
            $operator = isset($extract['operator'])
                ? strtolower(trim($extract['operator'], ' ?'))
                : null;

            // implicit '=' or 'in'
            if(!$operator) {
                $operator = is_array($input)
                    ? reset($this->complexOperators)
                    : reset($this->simpleOperators);
            }

            // simple operators
            if(in_array($operator, $this->simpleOperators)) {
                if(is_array($input)) {
                    throw new \PDOException('Operator "' . $operator . '" needs only one input value, in "' . $condition . '"');
                }

                $condition = '`' . $field . '` ' . $operator . ' ?';
            }
            // complex operators
            elseif(in_array($operator, $this->complexOperators)) {
                if(!is_array($input) or empty($input)) {
                    throw new \PDOException('Operator "' . $operator . '" needs multiple input values, in "' . $condition . '"');
                }

                $placeholders = array_fill(0, count($input), '?');
                $condition = '`' . $field . '` ' . $operator . ' (' . implode(', ', $placeholders) . ')';
            }
            // tuple operators
            elseif(in_array($operator, $this->tupleOperators)) {
                if(!is_array($input) or count($input) != 2) {
                    throw new \PDOException('Operator "' . $operator . '" needs exactly two input value, in "' . $condition . '"');
                }

                $condition = '`' . $field . '` ' . $operator . ' ? and ?';
            }
            // unknown operator
            else {
                throw new \PDOException('Invalid operator in "' . $condition . '"');
            }

            $this->where[$condition] = $input;
        }

        return $this;
    }
public function where($expression, $value = null)
    {
        // shortcut : id
        if(is_int($expression) and !$value) {
            $expression = ['id' => $expression];
        }
        // force array
        elseif(!is_array($expression)) {
            $expression = [$expression => $value];
        }

        // parse each expression
        foreach($expression as $condition => $input) {

            // parse condition
            if(!preg_match('/^(?P<field>[a-zA-Z_0-9]+)( (?P<operator>.+))?$/', $condition, $extract)) {
                throw new \PDOException('Invalid expression "' . $condition . '"');
            }

            // clean condition
            $field = trim($extract['field']);
            $operator = isset($extract['operator'])
                ? strtolower(trim($extract['operator'], ' ?'))
                : null;

            // implicit '=' or 'in'
            if(!$operator) {
                $operator = is_array($input)
                    ? reset($this->complexOperators)
                    : reset($this->simpleOperators);
            }

            // simple operators
            if(in_array($operator, $this->simpleOperators)) {
                if(is_array($input)) {
                    throw new \PDOException('Operator "' . $operator . '" needs only one input value, in "' . $condition . '"');
                }

                $condition = '`' . $field . '` ' . $operator . ' ?';
            }
            // complex operators
            elseif(in_array($operator, $this->complexOperators)) {
                if(!is_array($input) or empty($input)) {
                    throw new \PDOException('Operator "' . $operator . '" needs multiple input values, in "' . $condition . '"');
                }

                $placeholders = array_fill(0, count($input), '?');
                $condition = '`' . $field . '` ' . $operator . ' (' . implode(', ', $placeholders) . ')';
            }
            // tuple operators
            elseif(in_array($operator, $this->tupleOperators)) {
                if(!is_array($input) or count($input) != 2) {
                    throw new \PDOException('Operator "' . $operator . '" needs exactly two input value, in "' . $condition . '"');
                }

                $condition = '`' . $field . '` ' . $operator . ' ? and ?';
            }
            // unknown operator
            else {
                throw new \PDOException('Invalid operator in "' . $condition . '"');
            }

            $this->where[$condition] = $input;
        }

        return $this;
    }
Filter by conditions

@param string $expression
@param mixed $value
@return $this