public static function getLatestCommentsbyCompetitorId($competitorId, $limit = 1) { $model = new Default_Model_Comments(); $select = $model->getMapper()->getDbTable()->select()->from(array('comments'), array('id', 'name', 'comment', 'created'))->where('competitorId = ?', $competitorId); $select->where('status = ?', '1'); $select->order('created DESC')->where('NOT deleted'); $select->limit($limit); if ($limit == 1) { $result = $model->fetchRow($select); } else { $result = $model->fetchAll($select); } return $result; }
public function indexAction() { $model = new Default_Model_Comments(); $select = $model->getMapper()->getDbTable()->select()->from(array('c' => 'comment'), array('c.*'))->where("NOT c.deleted")->where("c.idParent IS NULL")->order(array('c.created DESC')); $result = $model->fetchAll($select); if (NULL != $result) { $paginator = Zend_Paginator::factory($result); $paginator->setItemCountPerPage(25); $paginator->setCurrentPageNumber($this->_getParam('page')); $paginator->setPageRange(5); $this->view->result = $paginator; $this->view->itemCountPerPage = $paginator->getItemCountPerPage(); $this->view->totalItemCount = $paginator->getTotalItemCount(); Zend_Paginator::setDefaultScrollingStyle('Sliding'); Zend_View_Helper_PaginationControl::setDefaultViewPartial('_pagination.phtml'); } }