public function count()
    {
        if (isset($this->_resultset)) {
            return $this->_resultset->count();
        } elseif (isset($this->_limit) || isset($this->_group)) {
            return $this->execute()->count();
        } else {
            $query = clone $this;

            return (int)$query->select("count(*) count")->execute()->scalar();
        }
    }