/** * 内容查询 * */ public function searchAction() { //获取页面提交参数 $keyWord = urldecode($this->_request->getParam('keyWord')); $page = $this->_request->getParam('page'); $this->view->keyWord = urlencode($keyWord); //关键字数组 $keywordsStrArray = explode(' ', $keyWord); $this->view->keywordsStrArray = $keywordsStrArray; //开始查询 $array = array(); //新闻 $model = new Model_DbTable_News(); $infos = $model->findByLike($keyWord); $tmpArray = array(); foreach ($infos as $info) { $tmpArray['flag'] = 0; $tmpArray['id'] = $info['id']; $tmpArray['title'] = $info['title']; $tmpArray['uncontent'] = $info['uncontent']; $tmpArray['addtime'] = $info['addtime']; array_push($array, $tmpArray); } //分页参数 if ($page == null) { $page = 1; } $pageRange = 10; $itemCountPerPage = 10; //实例并构建Zend_Paginator对象 $paginatorAdapter = new Zend_Paginator_Adapter_Array($array); $paginator = new Zend_Paginator($paginatorAdapter); $paginator->setPageRange($pageRange)->setItemCountPerPage($itemCountPerPage)->setCurrentPageNumber($page); $this->view->paginator = $paginator; //设置布局 $this->_helper->layout->disableLayout(); //页面信息 $this->view->title = '内容查询-' . $this->_config['pageInfo']['default']['title']; }