Home PHP Framework ThinkPHP 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

Aug 28, 2020 pm 04:54 PM
thinkphp update

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 of this Website
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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to run thinkphp project How to run thinkphp project Apr 09, 2024 pm 05:33 PM

To run the ThinkPHP project, you need to: install Composer; use Composer to create the project; enter the project directory and execute php bin/console serve; visit http://localhost:8000 to view the welcome page.

There are several versions of thinkphp There are several versions of thinkphp Apr 09, 2024 pm 06:09 PM

ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

How to run thinkphp How to run thinkphp Apr 09, 2024 pm 05:39 PM

Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

Which one is better, laravel or thinkphp? Which one is better, laravel or thinkphp? Apr 09, 2024 pm 03:18 PM

Performance comparison of Laravel and ThinkPHP frameworks: ThinkPHP generally performs better than Laravel, focusing on optimization and caching. Laravel performs well, but for complex applications, ThinkPHP may be a better fit.

Development suggestions: How to use the ThinkPHP framework to implement asynchronous tasks Development suggestions: How to use the ThinkPHP framework to implement asynchronous tasks Nov 22, 2023 pm 12:01 PM

"Development Suggestions: How to Use the ThinkPHP Framework to Implement Asynchronous Tasks" With the rapid development of Internet technology, Web applications have increasingly higher requirements for handling a large number of concurrent requests and complex business logic. In order to improve system performance and user experience, developers often consider using asynchronous tasks to perform some time-consuming operations, such as sending emails, processing file uploads, generating reports, etc. In the field of PHP, the ThinkPHP framework, as a popular development framework, provides some convenient ways to implement asynchronous tasks.

KDE Plasma 6.1 brings many enhancements to the popular Linux desktop KDE Plasma 6.1 brings many enhancements to the popular Linux desktop Jun 23, 2024 am 07:54 AM

After several pre-releases, the KDE Plasma development team unveiled version 6.0 of its desktop environment for Linux and BSD systems on 28 February, using the Qt6 framework for the first time. KDE Plasma 6.1 now comes with a number of new features t

Solution to high CPU usage of Microsoft compatibility telemetry Solution to high CPU usage of Microsoft compatibility telemetry Mar 16, 2024 pm 10:16 PM

When we use the win10 system, we sometimes encounter situations where the computer becomes stuck. Then when we check the background process, we find that a Microsoftcompatibilitytelemetry process takes up a particularly high amount of resources. So what is going on? Users can try to uninstall the third-party protection software and then try a clean boot to operate. Let this site carefully introduce to users the solution to the high CPU usage of Microsoftcompatibilitytelemetry. Solution to the high CPU usage of Microsoftcompatibilitytelemetry Method 1: Try after uninstalling the third-party protection software

How to install thinkphp How to install thinkphp Apr 09, 2024 pm 05:42 PM

ThinkPHP installation steps: Prepare PHP, Composer, and MySQL environments. Create projects using Composer. Install the ThinkPHP framework and dependencies. Configure database connection. Generate application code. Launch the application and visit http://localhost:8000.

See all articles