This time to everyone to bring thinkPHP5 framework to implement the page query steps in detail, thinkPHP5 framework to achieve the attention of the paging query, the following is the actual case, take a look.
Controller file inside admin.php
<?phpnamespace app\admin\controller;use think\controller;use app\admin\model\admin as AdminModel; Resolving class name conflicts using pagination class alias class Admin extends controller{public function lst () {/* page start */$list = Adminmodel::p aginate (3); $this-Assign (' list ', $list);/* end */return $this->fetch (' lst '); The Public function Add () {///Determines whether the page submits an if (Request ()->ispost ()) {//Prints the received parameter//dump (' post. '); $data = [//Accept the passed parameter ' username ' = ' = ' = ' username ', ' password ' = MD5 (input (' password ')),];/* Certificate Start */$validate = \think\loader::validate (' Admin '); /* Scene (' Add ') add a validation app on the Add page */if (! $validate-Scene (' Add '), check ($data)) {/* validation failed printing */$thi S-Error ($validate->geterror ()); Die }/* End */* DB (' table name ') Database helper function */if (db (' admin '), insert ($data)) {//Add data Return $this->success (' Add successful ', ' lst '); After successful jump to the LST interface}else{return $this->error (' Add Administrator failed '); } Return } return $this->fetch (' Add '); }}
Model file Inside admin.php
<?phpnamespace app\admin\model;use think\model;class Admin extends model{}
Lst.html
<! DOCTYPE html>
Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!
Recommended reading:
PHP uses file locks to resolve high concurrency steps
Php+ajax Implementing a blog post add Category function step