public function showCollect()
 {
     $userId = session('userId');
     $where['user_id'] = $userId;
     $collect = M('collection');
     $data = $collect->field('book.book_id as bookid,book.book_name as bookname,book.book_pic as pic')->join('book ON collection.book_id = book.book_id')->where(array('collection.user_id' => $userId))->page($_GET['p'] . ',3')->select();
     $this->assign('list', $data);
     // 赋值数据集
     $count = $collect->field('book.book_id as bookid,book.book_name as bookname,book.book_pic as pic')->join('book ON collection.book_id = book.book_id')->where(array('collection.user_id' => $userId))->count();
     // 查询满足要求的总记录数
     $Page = new PageTestController($count, 3);
     // 实例化分页类 传入总记录数和每页显示的记录数
     $show = $Page->show();
     // 分页显示输出
     $this->assign('collectPage', $show);
     // 赋值分页输出
     $collectSum = $count;
     $this->assign('collectSum', $collectSum);
     $this->assign('collectInfo', $data);
 }
 public function doSearch()
 {
     if (IS_POST) {
         $search = I('search');
         $book = M('book');
         $where['book_name'] = array('like', '%' . $search . '%');
         $count = $book->field('book_id,book_pic,book_name,book_price,book_pub_time')->where($where)->count();
         if ($count > 0) {
             $list = $book->field('book_id,book_pic,book_name,book_price,book_pub_time')->where($where)->order('book_pub_time')->page($_GET['p'] . ',3')->select();
             $this->assign('list', $list);
             $this->assign('result', $count);
             $Page = new PageTestController($count, 3);
             $show = $Page->show();
             // 分页显示输出
             $this->assign('page', $show);
             // 赋值分页输出
         } else {
             $this->assign('result', '');
         }
     } else {
         $this->error('页面不存在');
     }
     $this->display('search');
 }