thinkphp Lectures (10)--Introduction of third-party classes: paging-based

Source: Internet
Author: User

Introduction of third-party classes, for example, for pagination classes:

1. How to create a new paging method in the controller fenye ()

Note: The third-party class Page.class.php is placed in the think or Home folder, and a new folder is placed inside, and the namespace is added to its class namespace Home\fenye

function Fenye () {$model =d ("Nation"), $total = $model->count ();//Page Class $page=new \home\fenye\page ($total, 3);  Parameter one is the total number of data; parameter two: number of bars per page//$sql = "SELECT * from Nation". $page->limit;  Original Ecological statement//$attr = $model->query ($sql);  Query () method, and adding and deleting instead of using the Execute () method $attr= $model->limit ($page->limit)->select (); $xinxi = $page->fpage (); This->assign ("Xinxi", $xinxi), $this->assign ("Nation", $attr); $this->display ();}

2. New front-end Display page fenye.html

<body><table><tr>   <td> Code </td>   <td> name </td></tr>< foreach Name= "Nation" item= "V" ><tr>   <td><{$v .code}></td>   <td><{$ v.name}></td></tr></foreach></table><div><{$xinxi}></div></ Body>

  

thinkphp Lectures (10)--Introduction of third-party classes: paging-based

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.