Simple CRUD Operations
1 Public functionShow () {2 $m=m (' User ');3 4 //$arr = $m->find (2);//Find id=2 data, find can only return a single piece of data5 //2.select * from ' Tp_user ' WHERE (sex=1)6 //$arr = $m->where (' sex=1 ')->select ();7 8 //3.insert into ' tp_user ' (' username ', ' sex ') VALUES (' Harry ', 1)9 //$m->username22= "Wangsi";Ten //$m->seeee=1; If the corresponding field name is not correct, do not join, so to set whether it is empty, or the default value One //$arr = $m->add (); Returns the ID of the add successful corresponding A - - //4.delete from ' Tp_user ' WHERE (' id ' = 2) the //$arr = $m->delete (2); Returns the number of deleted success Bars - - //3.delete from ' Tp_user ' WHERE (sex=0) - //$arr = $m->where (' sex=0 ')->delete (); + - //2.UPDATE ' tp_user ' SET ' username ' = ' li Ming ', ' Sex ' =0 WHERE (' id ' = 1) + $data[' ID ']=4; A $data[' username ']= ' li Ming 2 '; at $data[' Sex ']=0; - $arr=$m->save ($data);//returns the number of successful executions - Echo $arr; - - $this-display (); -}
thinkphp study 07