Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the meaning of orm in php

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, the editor will share with you the relevant knowledge of what orm means in php. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.

In php, the full name of ORM is "Object-Relationl Mapping", which means "object-relational mapping", which is simply a mapping between object model and relational model. The main purpose of ORM is to map the objects represented by the object model to the relational model database structure based on sql.

Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

What does orm mean?

O = Object

RM- > Relational (Relational) Mapping (Mapping)

Object-Relationl Mapping is simply a mapping between the object model and the relational model.

What does ORM stand for:

Database table (table)-- > class (class)

Record (record, row data)-> object (object)

Field (field)-> property of the object (attribute)

Its function is to make a mapping between the relational database and the object, so that when we operate the database, we no longer need to deal with complex SQL statements, as long as we operate it as usual.

For example: to get an article, the traditional way is to perform a sql to retrieve data.

Select * from post where id = 1

Then output the title and content to use

Echo $post ['title']; echo $post [' content']

When the above code encounters object-oriented obsessive-compulsive disorder, they will struggle to death.

So they came up with this thing, and you can get an article in ORM like this:

$post = postTable::getInstance ()-> find (1); # will execute select * from post where id = 1 internally

Then output:

Echo $post- > getTitle (); echo $post- > getContent ()

Mom doesn't have to worry about my obsessive-compulsive disorder anymore.

The application of advanced points, articles and categories are one-to-many relationships, and articles and tags are many-to-many relationships.

$cate = $post- > getCategory (); / / get the article category echo $cate- > getName (); / / get the category name $tags = $post- > getTags (); / / get all the tags of an article

Did you get all the data we need without even writing a sql? Using ORM, we can implement applications without writing sql at all, and these ORM have been done for us.

In addition, orm can isolate the underlying database layer, and we don't need to care whether we are using mysql or other relational databases.

The orm I know: doctrine and propel

In addition to orm, there is also odm, or object document mapping, object document mapping, which is used when using document databases such as mongodb

These are all the contents of the article "what is the meaning of orm in php?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report