Advantages and disadvantages of ORM

Source: Internet
Author: User

Four core concepts of ORM:

· Simple: Orm models data in the most basic form. For example, The ORM maps a MySQL table into a PHP class (model), and the field of the table is the member variable of this class.

· Precision: Orm allows all MySQL data tables to be accurately mapped to PhP classes according to unified standards, so that the system remains accurate and unified at the code level.

· Easy to understand: Orm makes the database structure document. For example, MySQL databases are converted by ORM to PhP classes that PHP programmers can understand. PHP programmers can focus only on the PHP level they are good at (of course, they can master MySQL better)

· Ease of use: The ORM avoids nonstandard, redundant, and inconsistent style SQL statements, can avoid many human bugs, and facilitates the unification of encoding styles and subsequent maintenance.

Orm generally provides common interface functions for data models, such as: Create (), update (), save (), load (), find (), find_all (), where (), that is, SQL queries are all encapsulated into functions in the programming language, and the final SQL statements are generated through the chained combination of functions.

From this point of view, the benefits of ORM for agile development and cooperative development are very great. Here is a list of the notable advantages of ORM:

· It greatly shortens the coding time of programmers, reduces or even removes model Encoding

· Good database operation interfaces reduce coding difficulty and simplify the code of team members.

· Dynamic data table ing reduces code modifications when the data table structure or even database changes

· Reduced the programmer's learning cost for the database

· You can easily introduce additional functions such as data caching.

However, Orm is not perfect, and it also has its own inevitable disadvantages:

· Automated relational database ing consumes system performance. In fact, the performance consumption here is good. Generally, it can be ignored, especially when cacha exists.

· When processing queries with complex multi-table join queries and where conditions, The ORM syntax becomes complex and cumbersome.

· The more powerful the Orm, the more memory is consumed, because an ORM object will carry many member variables and member functions. Once I fixed the bug, I met it. I used 12 Mb of memory for ORM queries, and I used only 1.7 MB for SQL queries ......

For general web application development, the use of ORM can indeed bring many of the above benefits, and in most cases it does not involve the bad performance of ORM. However, in the system where there is a large amount of data, a large amount of computation, and complex queries, do not use Orm. The performance problem of ORM will bring you a disaster. Here, you can use pure SQL or other simple and lightweight dB helper libraries. After learning more about Orm, you can use it to maximize its effectiveness.

Reference: http://www.fancycedar.info/2013/01/orm/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.