/** * 搜索热词列表 * @date: 2016-1-14 * @author: futao */ public function hotlistAction() { $this->setLeftNav('hotlist'); $req = $this->request; $page = intval($req->getQuery('page', null, 1)); $page = $page > 0 ? $page : 1; $limit = $this->pageNavLimit; $offset = $limit * ($page - 1); $filterWord = $req->getQuery('keyword', null, ''); $filterstate = $req->getQuery('status', null, ''); if ($filterWord != '') { $where[] = 'title like "%' . $filterWord . '%"'; } if ($filterstate != '') { $where[] = 'status = ' . $filterstate; } if (count($where) > 0) { $whereStr = implode(" and ", $where); $wordModel = QuestionHotWords::query()->where($whereStr); } else { $wordModel = QuestionHotWords::query(); } $list = $wordModel->limit($limit, $offset)->orderBy('id desc')->execute()->toArray(); $total = QuestionHotWords::count($whereStr); $this->view->setVar('state', $filterstate); $this->view->setVar('keyword', $filterWord); $this->view->setVar('list', $list); $this->view->setVar('page', $page); $this->view->setVar('limit', $limit); $this->view->setVar('total', $total); }