final public function count($table = '', $resetselect = true)
    {

        if (!empty($table)) {
            $this->traceTableAlias($table);
            $this->fromTable($table);
        }
        $sql = $this->compile($this->_countString . $this->identifiers('totalcount'), true);
        $statement = $this->DBO->prepare($sql);

        $results = $statement->execute();

        if ($resetselect) $this->resetSelect();
        if ($results->rowCount() == 0) return '0';

        $row = $results->fetchObject();

        return $row->totalcount;
    }