Thinkphp $ model_user-& gt; create ($ data) data format incorrect & nbsp; protected & nbsp; $ _ validate & nbsp ;=& nbsp; array (& nbsp; & nbsp; array ('name' thinkphp $ model_user-> create ($ data) data format incorrect
Protected $ _ validate = array (
Array ('name', 'require ', 'user name cannot be blank '),
Array ('passwd', 'require ', 'password cannot be blank ')
);
Function login (){
$ Model_user = D ("User ");
$ Data = array (
'Name' => $ this-> _ post ('name '),
'Passwd' => $ this-> _ post ('passwd ')
);
If (! $ Model_user-> create ($ data )){
$ This-> error ($ model_user-> getError (), U ('UC/login '));
} Else {
}
For example, I want to perform automatic login verification.
------ Solution --------------------
If LZ has changed the data table structure, clear the cache and try again. If not, paste the getError information.
------ Solution --------------------
...... Why do I need to log on to create ($ data )...... Not where ($ data)-> select ()?
------ Solution --------------------
Reference:
...... Why do I need to log on to create ($ data )...... Not where ($ data)-> select ()?
Tp performs three automatic operations during the create operation.
------ Solution --------------------
CREATE does not need $ data.
------ Solution --------------------
Let's take a look at the create () method.