Home  >  Article  >  PHP Framework  >  High energy ahead, some students are stumped by the update of the TP model

High energy ahead, some students are stumped by the update of the TP model

咔咔
咔咔Original
2020-08-28 16:54:242142browse

This article will talk about the update method of the model in the TP framework.

Preface

##❝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!

High energy ahead, some students are stumped by the update of the TP model
##Insert picture description here

Let’s take a look at the usage given in the document first!

The previous usage of Kaka was like this. High energy ahead, some students are stumped by the update of the TP model

  • Introduce the model
  • Instantiate the model
  • Then use the query method of the database in the document

High energy ahead, some students are stumped by the update of the TP modelThis classmate made a mistake using this method, so Kaka directly used the static calling method to demonstrate to everyone. As follows

High energy ahead, some students are stumped by the update of the TP modelAt 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! High energy ahead, some students are stumped by the update of the TP modelBu_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? High energy ahead, some students are stumped by the update of the TP modelAt 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.

High energy ahead, some students are stumped by the update of the TP modelAfter 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!

High energy ahead, some students are stumped by the update of the TP modelSure 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn