ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# thinkphp 自由查询语句分页 ``` $search = I('get.k'); $sql="select a.title casetitle,a.default_pic,a.id caseid,b.title classtitle from `case` a,case_class b where a.case_class=b.id"; if (!empty($search)) { $sql=$sql." and a.title like '%$search%'"; } $q = M(); $pagesize = I('get.pagesize', 2, 'intval'); $count = count($q->query($sql));//总计条数 echo $count.$pagesize; $Page = new HelpBasePage($count, $pagesize, array(), false); // 实例化分页类 传入总记录数和每页显示的记录数(5) $list=$q->query($sql." limit $Page->firstRow,$Page->listRows"); $show = $Page->show(); $this->assign('pagination', $show); $this->assign('list', $list); $this->assign('search', $search); $this->display(); ```