src/Budkit/Datastore/Activerecord.php
final public function where($key, $value = NULL, $type = 'AND', $escape = TRUE)
    {

        if (empty($key)) {
            return $this;
        }
        if (!is_array($key)) {
            if (is_null($value)) { //some values could be ''
                return $this;
            }
            $key = array($key => $value);
        }

        //print_R($key);

        foreach ($key as $k => $v) {

            //The firs item adds the and prefix;
            $prefix = (count($this->arrayWhere) == 0 AND count($this->arrayCacheWhere) == 0) ? '' : $type . "\t";

            if (is_null($v) && !$this->hasOperator($k)) {
                // value appears not to have been set, assign the test to IS NULL
                $k .= ' IS NULL';
            }
            if (!is_null($v)) {
                if ($escape === TRUE) {
                    $k = $this->identifiers($k);
                    $v = '' . $this->escape($v);
                    //$v = $this->quote( stripslashes($v) );
                }
                if (!$this->hasOperator($k)) {
                    $k .= ' =';
                }
            } else {
                $k = $this->identifiers($k);
            }
            $this->arrayWhere[] = $prefix . $k . $v;

            if ($this->arrayCaching) {
                $this->arrayCacheWhere[] = $prefix . $k . $v;
                $this->arrayCacheExists[] = 'where';
            }
        }

        return $this;
    }
final public function where($key, $value = NULL, $type = 'AND', $escape = TRUE)
    {

        if (empty($key)) {
            return $this;
        }
        if (!is_array($key)) {
            if (is_null($value)) { //some values could be ''
                return $this;
            }
            $key = array($key => $value);
        }

        //print_R($key);

        foreach ($key as $k => $v) {

            //The firs item adds the and prefix;
            $prefix = (count($this->arrayWhere) == 0 AND count($this->arrayCacheWhere) == 0) ? '' : $type . "\t";

            if (is_null($v) && !$this->hasOperator($k)) {
                // value appears not to have been set, assign the test to IS NULL
                $k .= ' IS NULL';
            }
            if (!is_null($v)) {
                if ($escape === TRUE) {
                    $k = $this->identifiers($k);
                    $v = '' . $this->escape($v);
                    //$v = $this->quote( stripslashes($v) );
                }
                if (!$this->hasOperator($k)) {
                    $k .= ' =';
                }
            } else {
                $k = $this->identifiers($k);
            }
            $this->arrayWhere[] = $prefix . $k . $v;

            if ($this->arrayCaching) {
                $this->arrayCacheWhere[] = $prefix . $k . $v;
                $this->arrayCacheExists[] = 'where';
            }
        }

        return $this;
    }
final public function where ( $ key , $ value = NULL , $ type = 'AND' , $ escape = TRUE ) { if ( empty ( $ key ) ) { return $ this ; } if ( ! is_array ( $ key ) ) { if ( is_null ( $ value ) ) { //some values could be '' return $ this ; } $ key = array ( $ key => $ value ) ; } //print_R($key); foreach ( $ key as $ k => $ v ) { //The firs item adds the and prefix; $ prefix = ( count ( $ this -> arrayWhere ) == 0 AND count ( $ this -> arrayCacheWhere ) == 0 ) ? '' : $ type . "\t" ; if ( is_null ( $ v ) && ! $ this -> hasOperator ( $ k ) ) { // value appears not to have been set, assign the test to IS NULL $ k .= ' IS NULL' ; } if ( ! is_null ( $ v ) ) { if ( $ escape === TRUE ) { $ k = $ this -> identifiers ( $ k ) ; $ v = '' . $ this -> escape ( $ v ) ; //$v = $this->quote( stripslashes($v) ); } if ( ! $ this -> hasOperator ( $ k ) ) { $ k .= ' =' ; } } else { $ k = $ this -> identifiers ( $ k ) ; } $ this -> arrayWhere [ ] = $ prefix . $ k . $ v ; if ( $ this -> arrayCaching ) { $ this -> arrayCacheWhere [ ] = $ prefix . $ k . $ v ; $ this -> arrayCacheExists [ ] = 'where' ; } } return $ this ; }
Adds a WHERE condition to the Query statement.
NOTE, to change the operatory, append the desired operator to the key names
for example use

where('a >', 'b'); to add an a > b rule to the statement
where( array('a >'=>'b','a <'='c') );

@param mixed $key string with a single field key or array of key value pairs
@param string $value If $key is string, then a sing $single String to specify the value
@param string $type if adding more than one WHERE clause, use AND, OR etc..
@param boolean $escape . Should we escape the identifiers in the statement?
@return TuiyoDatabase
Adds a WHERE condition to the Query statement . NOTE to change the operatory append the desired operator to the key names for example use