search
HomePHP FrameworkThinkPHPDoes thinkphp have an orm?

Does thinkphp have an orm?

THinkPHP is a relatively representative PHP development framework in China and supports the MVC development model. ThinkPHP's ORM (Object Relation Mapping) is a storage access layer for developers to use database development. The framework design picture is as follows:

Does thinkphp have an orm?

thinkPHP ORM framework adopts Active Record mode ( (referred to as AR) to design and implement.

Related recommendations: "ThinkPHP Tutorial"

What is Active Record mode?

is to use an AR class to associate a table in the database. Each AR object corresponds to a row of data in the table; the attributes of the object are mapped to the corresponding columns of the data row.

For example, a Customer AR class is associated with the customer table in the database, and the name attribute of the AR class represents the field named name in the customer table.

In thinkPHP, the base class of all AR classes is the Model class. The Model class is associated with the table in the database by name. The constructor of the Model class is as follows:

public function __construct($name='',$tablePrefix='',$connection='')
@param string  $name 模型名称
* @param string $tablePrefix 表前缀
* @param mixed  $connection 数据库连接信息

Data CURD of the Model class (create, update, retrieve, delete) operations are implemented through the concrete implementation of the database abstract class Driver, so that MySQL or Oracle can be conveniently used through configuration.

Through this design implementation, the following benefits can be obtained:

1. Whether the specific database is MySQL, Oracle, or switching from MySQL to Oracle, the code above the driver implementation does not Will be affected in any way;

2. The database table is mapped to the AR class, and the CURD operation of the database is interpreted and executed by the AR class, which is in line with the object-oriented design idea; and it is separated from the writing of specific SQL statements, and the code More concise and less error-prone.

The above is the detailed content of Does thinkphp have an orm?. 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

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!