Not very like the TP of the paging class, because the generated paging URL feels a little difficult to understand, such as access path xxxx/home/show.html, after the template output pagination, for example, the page number is generated, the link to the page number of the path will become xxxx/home/show/p/page number. html. I don't like this path very much, but it doesn't matter. It will be good to use it for a long time.
$sql= "Select F.*,d.dname,from_unixtime (f.createtime, '%y-%m-%d ') createdate,"
." From_unixtime (f.updatetime, '%y-%m-%d ') updatedate "
." From ". C (' Db_prefix '). " File F left JOIN ". C (' Db_prefix '). " Dir d on f.did = D.did where 1=1 ";
if(!Empty($post[' filename ']) {
$sql. = "and f.filename like '%".$post[' filename ']. %‘ ";
}
if(!Empty($post[' did '])) {
$sql. = "and f.did= '".$post[' Did ']. "'";
}
//$result = $file->query ($sql);
$count=Count($file->query ($sql));
$page=New\think\page ($count, page_size);
//$page->parameter = $post [' did '];//The row here is an array, in order to pass the query condition
$page->setconfig (' first ', ' home ');
$page->setconfig (' prev ', ' prev ');
$page->setconfig (' Next ', ' next page ');
$page->setconfig (' Last ', ' End ');
$pageSetconfig (' header ', ' <span class= ' rows ' > Total <b>%TOTAL_ROW%</b> Records Section <b>%now_page%</b > page/Total <b>%TOTAL_PAGE%</b> page </span> ');
$page-Setconfig (' theme ', '%first%%up_page%%link_page%%down_page%%end%%header% ');
$show=$page->show ();
$sql. = "LIMIT".$page->firstrow. ",".$page->listrows;
$result=$file->query ($sql);
As the above code, the Query method is used for querying the custom sql,page initialization needs to pass 2 parameters, SQL data total number of bars, page number of pages, through the Setconfig function to make the related Page object definition, the Show method generates paging html,$ Pager provides the 2 properties of Firestrow and lastrows to support paging, which can be paged by stitching SQL or the limit () function provided by model.
thinkphp 3.2.3 Pager Pagination