thinkphp Curd 1

Source: Internet
Author: User

Second, thinkphp 3 read data (emphasis)
Read to the data
$m =new Model (' User ');
$m =m (' User ');

Select
$m->select ();//Get all the data, return as an array

Find
$m->find ($id);//Get Single data

GetField (field name)//Get a specific field value to take a piece of data
$arr = $m->where (' id=2 ')->getfield (' username ');

Iii. thinkphp 3 Creating data (Focus)
Adding data to the Create
$m =new Model (' User ');
$m =m (' User ');
$m, field name = value
$m->add ();
The return value is the new ID number

$m = m (' User ');
$m->name= ' hahaha ';
$m->password=md5 (' 123456 ');
$result = $m->add ();

Iv. thinkphp 3 Delete data (focus)
$m =m (' User ');
$m->delete (2); Delete Data with ID 2
$m->where (' id=2 ')->delete (); Same as above, also delete data with ID 2
The return value is the number of rows affected
V. thinkphp 3 Update data (emphasis)
$m =m (' User ');
$data [' id ']=1;
$data [' username ']= ' ztz2 ';
$m->save ($data);
The return value is the number of rows affected

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.