search
HomePHP FrameworkThinkPHPwhat is model in thinkphp

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!

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

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

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.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment