protected function buildSelectQuery($table, $where = array(), $fields = '*', $order = array(), $limit = 0) {
        if(is_array($fields)) {
            $selectfields = array();
            foreach($fields as $field => $value) {
                $selectfields[] = sprintf("`%s`", SafeString::makeSafe($value));
            }
            $fieldList = implode(', ', $selectfields);
        }
        else{$fieldList = '*';}
        
        $this->sql = sprintf("SELECT %s FROM `%s`%s%s%s;", $fieldList, SafeString::makeSafe($table), $this->where($where), $this->orderBy($order), $this->limit($limit));
        $this->key = md5($this->database.$this->sql.serialize($this->values));
    }