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;
    }