thinkphp implements fuzzy query and paging functions
$data = M("datainfo");
$projectsname = I('get.projectsname');//Fuzzy query field submitted by the front desk
// Query conditions
$where = "";
empty($projectsname)?($where=""):($where="status=1 and projectsname like '%".$projectsname."%' or projectsname like '%".$projectsname."' or projectsname like '".$projectsname."%'");
$count = $data->where($where)->count(); // Query the total number of records that meet the requirements
$Page = new Page($count, 50); // Instantiate the paging class and pass in the total number of records and the number of records displayed on each page (50)
// Configure the display page of the front page
$Page->setConfig('header', 'Total %TOTAL_ROW% items');
$Page->setConfig('first', 'Homepage');
$Page->setConfig('last', 'Total %TOTAL_PAGE% pages');
$Page->setConfig('prev', 'Previous page');
$Page->setConfig('next', 'next page');
$Page->setConfig('link', 'indexpagenumb'); //pagenumb will be replaced with page number
$Page->setConfig('theme', '%HEADER% %FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%');
// Display output in pagination
$show = $Page->show();
// Perform paging data query. Note that the parameters of the limit method must use the attributes of the Page class
$list = $data->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select ();
$this->assign('page', $show);
$this->assign("list", $list);
NodeController.class.zip (1.08 KB Download: 3 times)