public function index() { $pagesize = 10; $page = max(1, I('get.p')); //取出现有书籍 $page_list = D('Book')->where($map)->page($page, $pagesize)->select(); $count = D('Book')->where($map)->count(); $Page = new \Think\PageBook($count, $pagesize); // 实例化分页类 传入总记录数和每页显示的记录数 $this->assign('page_list', $page_list); $this->assign('pages', $Page->show()); $this->display(); }
public function search() { $pagesize = 10; $page = max(1, I('get.p')); $keyword = I('get.keyword'); //取出现有书籍 $map['title'] = array('like', "%{$keyword}%"); $page_list = D('Book')->where($map)->page($page, $pagesize)->select(); $count = D('Book')->where($map)->count(); $Page = new \Think\PageBook($count, $pagesize); // 实例化分页类 传入总记录数和每页显示的记录数 $this->assign('page_list', $page_list); $this->assign('pages', $Page->show()); $this->assign('keyword', $keyword); $this->display(''); }
public function newpartlist() { $bookid = I('get.bookid'); $detail = D('Book')->where('id=' . $bookid)->find(); //$contents = I('get.contents'); //取出列表 $map['bookid'] = $bookid; $contents = 1; if (!$contents) { //$chapter_list = D('BookChapter')->where($map)->order('`index`, rank DESC')->field('title AS text, `index`, rank')->select(); //取出前20章 $firstPage = D('BookChapter')->where($map)->order('`index`, rank DESC')->field('title, `index`, rank')->limit(20)->select(); //倒叙前20章 $revertFirstPage = D('BookChapter')->where($map)->order('`index` DESC, rank DESC')->limit(20)->select(); krsort($revertFirstPage); $this->assign('first_page_list', $firstPage); $this->assign('revert_first_page_list', $revertFirstPage); } else { //取出所有章节 $page = I('get.p'); $orderDirection = I('get.orderDirection') == 'desc' ? 'desc' : 'asc'; $order = '`index` ' . $orderDirection . ', rank DESC'; $pagesize = 20; $chapter_list = D('BookChapter')->where($map)->order($order)->page($page, $pagesize)->field('title, `index`, rank')->select(); $count = D('BookChapter')->where($map)->count(); $Page = new \Think\PageBook($count, $pagesize); // 实例化分页类 传入总记录数和每页显示的记录数 $this->assign('orderDirection', $orderDirection); $this->assign('pages', $Page->show()); $this->assign('page_list', $chapter_list); } $this->assign('Detail', $detail); $this->assign('bookid', $bookid); $this->display(); }