/**
  * help $this->queryBuilder to construct a PHQL object
  * apply specified limit condition and return query object
  *
  * @param \Phalcon\Mvc\Model\Query\BuilderInterface $query            
  * @throws HTTPException
  * @return \Phalcon\Mvc\Model\Query\BuilderInterface $query
  */
 public function queryLimitHelper(\Phalcon\Mvc\Model\Query\BuilderInterface $query)
 {
     // only apply limit if we are NOT checking the count
     $limit = $this->searchHelper->getLimit();
     $offset = $this->searchHelper->getOffset();
     if ($offset and $limit) {
         $query->limit($limit, $offset);
     } elseif ($limit) {
         $query->limit($limit);
     } else {
         // can't have an offset w/o an limit
         throw new HTTPException("A bad query was attempted.", 500, array('dev' => "Encountered an offset clause w/o a limit which is a no-no.", 'code' => '894791981'));
     }
     return $query;
 }