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