Esempio n. 1
0
 /**
  * 文章列表
  * @return bool
  */
 public function listAction()
 {
     //$p = $this->getRequest()->getParam('p',1);
     $p = isset($_GET['p']) ? $_GET['p'] : 1;
     $query = [];
     $fields = [];
     $sort = ['time' => -1];
     $index = 0;
     $limit = 10;
     $article = new ArticleModel();
     // 查询文章数
     $count = $article->getArticleCount($query);
     // 查询文章列表
     $rows = $article->getArticleList($query, $fields, $sort, $index, $limit);
     $list = [];
     foreach ($rows as $v) {
         $v['date'] = date('Y-m-d H:i:s', $v['time']->sec);
         if ($v['update_time'] == 0) {
             $v['update_date'] = '--';
         } else {
             $v['update_date'] = date('Y-m-d H:i:s', $v['update_time']->sec);
         }
         $list[] = $v;
     }
     // 计算分页
     $pager = PagerLib::getPager($count, $limit, $p);
     $pagers = $pager['pagers'];
     $this->getView()->assign('list', $list);
     $this->getView()->assign('pagers', $pagers);
     return true;
 }