Home > Article > PHP Framework > High energy ahead, some students are stumped by the update of the TP model
❝This article will talk about the update method of the model in the TP framework.
❞
##❝Kaka has compiled a roadmap and created an interview guide, preparing to follow this roadmap I am writing an article, and I will add some knowledge points that have not been added later. I also hope that all my partners can help add them. See you in the comment area! ❞
The previous usage of Kaka was like this.
This classmate made a mistake using this method, so Kaka directly used the static calling method to demonstrate to everyone. As follows
At first glance, there is nothing wrong with this usage, and it is exactly the same as what the documentation says. The result is unsatisfactory, let's take a look at the error message.
This is very heartless, it is exactly the same as the document, why is there a lack of update conditions! Bu_id in this set of data is the primary key ID, that’s right!
There is no problem if you use it according to the documentation! Are you confused at this time? At this time, my classmates found me, so of course Kaka had to help solve it! Who makes me enthusiastic!
In fact, this problem cannot be said to be a problem, because it is not caused by a bug in the code, nor is there a problem with my own writing.
Follow Kaka’s footsteps to trace this issue. First open the document, navigate directly to the model chapter, and then look at the definition of the model.
There is a sentence like this. The default primary key of the model is id. If the primary key of the database design is not id, you need to set a pk attribute yourself.
After reading the above sentence, I think everyone understands that although the primary key in our table exists in our data. But this primary key is not the default model primary key id, so an error will occur.
Then it’s very simple! Just define the primary key of the data table in the model!
Sure enough, the problem was solved.
❝Persistence in learning, persistence in blogging, and persistence in sharing are the beliefs that Kaka has always upheld since his career. I hope that Kaka’s articles in the huge Internet can bring you a little Silk help. See you next time.
❞
The above is the detailed content of High energy ahead, some students are stumped by the update of the TP model. For more information, please follow other related articles on the PHP Chinese website!