Home > PHP Framework > ThinkPHP > body text

what is model in thinkphp

WBOY
Release: 2022-06-21 15:45:13
Original
3189 people have browsed it

In thinkphp, model refers to enterprise data and business rules. In actual project development, it mainly implements operations with the database; the naming of the model class needs to remove the database name of the table prefix and use camel case naming, and The first letter is capitalized, and the model class completes basic CURD, ActiveRecord mode, coherent operations, and statistical queries.

what is model in thinkphp

The operating environment of this article: Windows 10 system, ThinkPHP version 5, Dell G3 computer.

What is the model in thinkphp

Model (Model) is a very important concept in ThinkPHP, and it is also related to the definition and instantiation of the model.

MVC is a method of separating the logical layer and presentation layer of an application. ThinkPHP is also based on the MVC design pattern. The definition of model (M) in ThinkPHP is completed by the Model class.

The basic model class in ThinkPHP is the Model class, which completes basic CURD, ActiveRecord mode, coherent operations, statistical queries, etc.

1. What is a model?

The model represents enterprise data and business rules. In actual project development, it mainly implements operations with the database.

2. Model definition rules

The naming rule of the model class is to remove the table prefix from the data table name, use camel case naming, and capitalize the first letter, and then add Enter the keyword Model of the model class, plus the class file suffix .class.php

Case: Implementing the organizational structure function of the mobile office automation system

1. Design database db_think

2. Design data table structure (tk_dept)

what is model in thinkphp

3. Use SQL statements to create data tables

what is model in thinkphp

4 .Create a Dept controller

what is model in thinkphp

5.Import the add.html template to the ./Application/Admin/View/Dept folder

6.Change Images/css/js path information in the add.html page

7. Change the left navigation link of the office system, knowledge points to be used:

U method

Main function: used to generate navigation links, such as /index.php/Admin/Dept/add, the usage method is as follows

what is model in thinkphp

In actual project development we usually use the third type Method, U('module/controller/operation method')

what is model in thinkphp

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of what is model in thinkphp. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!