protected function paginate($qb, $pageOpts, $filters = array())
    {
        $db = $this->db;

        $total = count($db->fetchAll($qb->getSQL(), $filters));

        if (isset($pageOpts['start'])) {
            $qb->setFirstResult(isset($pageOpts['start']) ? $pageOpts['start'] : 0)
                ->setMaxResults(isset($pageOpts['limit']) ? $pageOpts['limit'] : 200);
        }

        $result = $db->fetchAll($qb->getSQL(), $filters);

        return array(
            'total' => $total,
            'results' => $result
        );
    }