search
HomePHP FrameworkThinkPHPHigh 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.

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools