public function where($field, $cond = UNDEFINED, $value = UNDEFINED, $kind = 'where')
    {
        if (is_array($field)) {
            // or conditions
            $or = $this->orExpr();
            foreach ($field as $row) {
                if (is_array($row)) {
                    $or->where(
                        $row[0],
                        array_key_exists(1, $row) ? $row[1] : UNDEFINED,
                        array_key_exists(2, $row) ? $row[2] : UNDEFINED
                    );
                } elseif (is_object($row)) {
                    $or->where($row);
                } else {
                    $or->where($or->expr($row));
                }
            }
            $field = $or;
        }

        if (is_string($field) && !preg_match('/^[.a-zA-Z0-9_]*$/', $field)) {
            // field contains non-alphanumeric values. Look for condition
            preg_match(
                '/^([^ <>!=]*)([><!=]*|( *(not|is|in|like))*) *$/',
                $field,
                $matches
            );
            $value = $cond;
            $cond = $matches[2];
            if (!$cond) {
                // IF COMPAT
                $matches[1] = $this->expr($field);
                if ($value && $value !== UNDEFINED) {
                    $cond = '=';
                } else {
                    $cond = UNDEFINED;
                }
            }
            $field = $matches[1];
        }

        $this->args[$kind][] = array($field, $cond, $value);

        return $this;
    }
public function where($field, $cond = UNDEFINED, $value = UNDEFINED, $kind = 'where')
    {
        if (is_array($field)) {
            // or conditions
            $or = $this->orExpr();
            foreach ($field as $row) {
                if (is_array($row)) {
                    $or->where(
                        $row[0],
                        array_key_exists(1, $row) ? $row[1] : UNDEFINED,
                        array_key_exists(2, $row) ? $row[2] : UNDEFINED
                    );
                } elseif (is_object($row)) {
                    $or->where($row);
                } else {
                    $or->where($or->expr($row));
                }
            }
            $field = $or;
        }

        if (is_string($field) && !preg_match('/^[.a-zA-Z0-9_]*$/', $field)) {
            // field contains non-alphanumeric values. Look for condition
            preg_match(
                '/^([^ <>!=]*)([><!=]*|( *(not|is|in|like))*) *$/',
                $field,
                $matches
            );
            $value = $cond;
            $cond = $matches[2];
            if (!$cond) {
                // IF COMPAT
                $matches[1] = $this->expr($field);
                if ($value && $value !== UNDEFINED) {
                    $cond = '=';
                } else {
                    $cond = UNDEFINED;
                }
            }
            $field = $matches[1];
        }

        $this->args[$kind][] = array($field, $cond, $value);

        return $this;
    }
public function where ( $ field , $ cond = UNDEFINED , $ value = UNDEFINED , $ kind = 'where' ) { if ( is_array ( $ field ) ) { // or conditions $ or = $ this -> orExpr ( ) ; foreach ( $ field as $ row ) { if ( is_array ( $ row ) ) { $ or -> where ( $ row [ 0 ] , array_key_exists ( 1 , $ row ) ? $ row [ 1 ] : UNDEFINED , array_key_exists ( 2 , $ row ) ? $ row [ 2 ] : UNDEFINED ) ; } elseif ( is_object ( $ row ) ) { $ or -> where ( $ row ) ; } else { $ or -> where ( $ or -> expr ( $ row ) ) ; } } $ field = $ or ; } if ( is_string ( $ field ) && ! preg_match ( '/^[.a-zA-Z0-9_]*$/' , $ field ) ) { // field contains non-alphanumeric values. Look for condition preg_match ( '/^([^ <>!=]*)([><!=]*|( *(not|is|in|like))*) *$/' , $ field , $ matches ) ; $ value = $ cond ; $ cond = $ matches [ 2 ] ; if ( ! $ cond ) { // IF COMPAT $ matches [ 1 ] = $ this -> expr ( $ field ) ; if ( $ value && $ value !== UNDEFINED ) { $ cond = '=' ; } else { $ cond = UNDEFINED ; } } $ field = $ matches [ 1 ] ; } $ this -> args [ $ kind ] [ ] = array ( $ field , $ cond , $ value ) ; return $ this ; }
Adds condition to your query.

Examples:
$q->where('id',1);

Second argument specifies table for regular fields
$q->where('id>','1');
$q->where('id','>',1);

You may use expressions
$q->where($q->expr('a=b'));
$q->where('date>',$q->expr('now()'));
$q->where($q->expr('length(password)'),'>',5);

Finally, subqueries can also be used
$q->where('foo',$q->dsql()->table('foo')->field('name'));

To specify OR conditions
$q->where($q->orExpr()->where('a',1)->where('b',1));

you can also use the shortcut:

$q->where(array('a is null','b is null'));

@param mixed  $field Field, array for OR or Expression
@param string $cond  Condition such as '=', '>' or 'is not'
@param string $value Value. Will be quoted unless you pass expression
@param string $kind  Do not use directly. Use having()

@return $this
Adds condition to your query .