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