These days, due to work needs, we create a membership Module Based on WBlog3.12. During the test and update of the member profile picture, thinkphp encountered a problem: the module model class cannot execute the update query statement! The following is a piece of code for updating data. The uploaded profile picture is successful. $ uploadList [0] [savename] is the name of the saved image obtained when the profile picture is updated, during debugging, make sure that the value of $ data [thumb] is not empty. The Code is as follows: Create a member Module Based on WBlog3.12 due to work needs these days.
A ThinkPHP problem was found during the test of updating the Member's profile picture:In the module model class, the update query statement cannot be executed!
The following is a piece of code for updating data. The uploaded avatar is successful. $ uploadList [0] ['savename'] indicates the name of the image that is successfully obtained when the Avatar is updated, during debugging, make sure that the value of $ data ['thumb'] is not empty. The Code is as follows:
Class AttachModel extends Model {... $ data ['thumb'] = $ uploadList [0] ['savename']; // obtain the name of the updated avatar. save $ list = M ('member ') -> where (array ('id' => 1)-> save ($ data );}
The above Code does not seem to have any errors. I think so, but it also takes me a lot of time to find errors in other code because it does not seem to have any errors, in the end, the problem occurs in the code snippet above -- put it in the controller, and the problem is solved. Haha, the test results are so painful!
After testing, it is okay to add data to the model class, that is, the above Code can be executed in this way.
Class AttachModel extends Model {... $ data ['thumb'] = $ uploadList [0] ['savename']; // obtain the name of the updated avatar. save $ list = M ('member ') -> where (array ('id' => 1)-> add ($ data); // save ($ data) change to add ($ data )...}
I checked the model class of the ThinkPHP core package. The class contains the add and save methods. As for the failure to execute save in the module model class, I am still confused, but at least it will not write the save in the model class.