thinkphp 3.2.3 Pager Pagination

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.