C Layer:
Public functionLogin_two () {$person=d (' person '); $data[' user_id '] = ' 28 '; $data[' name '] = '; $data[' password '] = ' 111111 '; //$data [' repassword '] = ' 12345 '; if($person->create ($data)){ $person-Save (); }Else { Var_dump($person-GetError ()); } }
M Layer:
//Auto-Complete protected $_auto=Array( //The string type can omit the following two Array(' remark ', ' remarks '),//function , password encryption, encryption type SHA1,SHA1 function PHP built-in (SHA1 is the number ' 1 ' is not the letter ' L ') Array(' Password ', ' SHA1 ', 3, ' function '),//populate the User field with the value of the email field Array(' remark ', ' name ', 3, ' field '),//callback, custom methods such as: prefix the user name Array(' name ', ' UpdateName ', 3, ' callback ', ' Hotel_ '),//Ignore, ignoring changes when the password is left blank for modification Array(' name ', ' ', 2, ' ignore '), ); //Custom Callback Functions protected functionUpdateName ($str,$prefix){ return $prefix.$str; }
The meaning of automatic completion (unknown sensation ... ):
Auto-Completion is a method that thinkphp provides for automatic data processing and filtering, and data processing is done automatically when the Create method is used.
Therefore, it is more secure to use the Create method in thinkphp for creating data objects, rather than implementing data writes directly through the Add or save methods.
Eon thinkphp Handout thinkphp--auto complete [14]