thinkphp3.2.3实现多条件查询实例.
$data = M("datainfo"); $projectsname = I('get.projectsname');//前台提交的模糊查询字段 // 查询条件 $where = ""; empty($projectsname)?($where=""):($where="status=1 and projectsname like '%".$projectsname."%' or projectsname like '%".$projectsname."' or projectsname like '".$projectsname."%'"); $count = $data->where($where)->count(); // 查询满足要求的总记录数 $Page = new Page($count, 50); // 实例化分页类 传入总记录数和每页显示的记录数(50) // 配置前台分页的显示页 $Page->setConfig('header', '共%TOTAL_ROW%条'); $Page->setConfig('first', '首页'); $Page->setConfig('last', '共%TOTAL_PAGE%页'); $Page->setConfig('prev', '上一页'); $Page->setConfig('next', '下一页'); $Page->setConfig('link', 'indexpagenumb'); //pagenumb 会替换成页码 $Page->setConfig('theme', '%HEADER% %FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%'); // 分页显示输出 $show = $Page->show(); // 进行分页数据查询 注意limit方法的参数要使用Page类的属性 $list = $data->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select(); $this->assign('page', $show); $this->assign("list", $list);
本文来自博客园,作者:7small7,转载请注明原文链接:https://www.cnblogs.com/qqblog/p/6529176.html