public function count($table, $where = array(), $cache = true) {
        $this->sql = sprintf("SELECT count(*) FROM `%s`%s;", SafeString::makeSafe($table), $this->where($where));
        $this->key = md5($this->database.$this->sql.serialize($this->values));
        
        $result = $this->executeQuery($cache);
        if(!$result) {
            $result = $this->query->fetchColumn();
            if($cache && $this->cacheEnabled) {$this->setCache($this->key, $result);}
        }
        return $result;
    }