CURD and ThinkPHPCURD operations in ThinkPHP
<? Php // query multiple records, returns a two-dimensional array $ result = M ("admin")-> 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); // deletes the record, and returns the 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")-> wher E ("id = 2")-> save ($ new_data); // execute 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 ();?>