ThinkPHP5 Framework implementation of paging query steps

Source: Internet
Author: User
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

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.