thinkphp basic additions and deletions to the operation of the example tutorial, thinkphp example Tutorial _php tutorial

Source: Internet
Author: User

thinkphp basic additions and deletions of the operation example Tutorial, thinkphp example Tutorial


This paper introduces the basic operation of thinkphp, which is the most commonly used in the development of thinkphp project, and has very important application value. Now the complete example code to share with you, I hope we can help. Specific as follows:

One, table aoli_user field settings:

Table Aoli_user has the following main fields:

ID Username Password Createtime createip

Second, view template part

1. User Homepage Template:

The aoli/home/tpl/default/user/index.html page code is as follows:

 
   
  
   
  • ID: {$VO [' id ']} User name: {$vo [' username ']} Registered IP: {$vo [' Createip ']} Delete edit
  • 2. User Edit Template:

    The aoli/home/tpl/default/user/edit.html page code is as follows:

    Second, action part:

    The aoli/home/lib/action/useraction.class.php page is as follows:

    Class Useraction extends Action {function index () {$user =m (' user ');     $list = $user->field (array (' ID ', ' username ', ' createip '))->select ();     $this->assign (' title ', ' thinkphp video demo ');     $this->assign (' alist ', $list);        $this->display ();     }//delete function del () {$user =d (' user ');        if ($user->delete ($_get[' id ')) {$this->success (' delete succeeded ');     }else{$this->error (' delete failed ');     }}//Add function Add () {Load (' extend ');        if ($_post[' password ']!=$_post[' Repassword ') {$this->error (' two times password inconsistent ');     } $user =d (' user ');       if ($vo = $user->create ()) {$user->password=md5 ($user->password);       $user->createtime=time ();       $user->createip=$_server[];       $user->createip=get_client_ip ();          if ($user->add ()) {$this->success (' User registration succeeded, return to Superior page ');       }else{$this->error (' User registration failed, return to Superior page ');        }}else{$this->error ($user->geterror ());  } }//Display the user's modifier function edit () {$user =m (' user ');     $id = (int) $_get[' id '];     $list = $user->where ("id= $id")->find ();     $this->assign (' data ', $list);      $this->assign (' title ', ' Show user edit information ');   $this->display ();     }//write update data to database function update () {$user =m (' user ');     $user->password=md5 ($user->password);       if ($user->create ()) {if ($insertid = $user->save ()) {$this->success (' Update succeeded, number of rows affected '. $insertid);          }else{$this->error (' update failed '); }}}}?>

    Interested readers can be debugged in the project to run the example described in this article, in order to deepen the understanding of the thinkphp additions and deletions of the operation, convenient for future projects in the flexible use.


    thinkphp framework under different modules of the change and delete permissions how to set

    You can consider RBAC.

    A thinkphp additions and deletions to check and change


    http://www.bkjia.com/PHPjc/868238.html www.bkjia.com true http://www.bkjia.com/PHPjc/868238.html techarticle thinkphp Basic additions and deletions of the operation example Tutorial, thinkphp example Tutorial This article describes thinkphp basic additions and deletions to check the operation, is the most commonly used in the development of thinkphp Project Basic operation, ...

  • Related Article

    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.