: This article mainly introduces the CURD operations in ThinkPHP. For more information about PHP tutorials, see.
Select (); $ result = M ("admin")-> where ("id> 2")-> select (); $ result = M ("admin ") -> where ("id> 2")-> order ("id desc")-> limit ("0, 5")-> field ("id, username, psssword ") -> select (); $ result = M ("admin")-> where ("id> 2")-> group ("messageId ") -> having ("messageId> 3")-> order ("id desc")-> limit ("0, 5")-> field ("id, username, psssword ") -> select (); // query a record and return a one-dimensional array $ result = M ("admin")-> find (); $ result = M ("admin ") -> where ("id = 2 ")-> Find (); // put the data to be processed in the array data $ data = array (" username "=> 'wang ', "password" => "123456"); // add a record, returns the number of affected rows $ updateRowNum = M ("admin")-> add ($ data); // delete a record, returned number of affected rows $ updateRowNum = M ("admin")-> where ("id = 2")-> delete (); // modify the data in the new array new_data $ new_data = array ("username" => 'Wang _ new', "password" => "123456_new"); // modify the record, returned number of affected rows $ updateRowNum = M ("admin")-> where ("id = 2")-> save ($ new_data); // run the select statement (Two-dimensional array is returned for all rows or rows) $ result = M ()-> query ("select * from admin a, user u where. id = user. aid "); // execute insert, update, and delete statements, and return the affected rows $ updateRowNum = M ()-> execute (" insert/update/delete Statement "); // calculate the number of queried rows (generally used for select statements) $ row = M ("admin")-> select ()-> count (); $ row = M ("admin ") -> where ("id> 3")-> select ()-> count ();?>
The above introduces the CURD operations in ThinkPHP, including some content, and hope to be helpful to friends who are interested in PHP tutorials.