public function setRowCount($rowCount)
    {
        if ($rowCount instanceof \Doctrine_Query) {
            $sql = $rowCount->getSql();

            if (false === strpos($sql, self::ROW_COUNT_COLUMN)) {
                throw new \Zend_Paginator_Exception('Row count column not found');
            }

            $result = $rowCount->fetchOne()->toArray();

            $this->_rowCount = count($result) > 0 ? $result[self::ROW_COUNT_COLUMN] : 0;
        } else if (is_integer($rowCount)) {
            $this->_rowCount = $rowCount;
        } else {
            throw new \Zend_Paginator_Exception('Invalid row count');
        }

        return $this;
    }