PHP ORM: (object/relation Mapping Object Relationship Mapping) humble opinion

Source: Internet
Author: User
ORM: (object/relation Mapping Object Relational mapping) the most famous ORM model should be the JAVA hibernate. ORM Basic Concepts:
Object-Relational mapping (relational Mapping, or ORM) is a technique for solving the mismatch between object-oriented and relational databases.
To put it simply, ORM uses __set __get __call, which is used to describe the mapping between objects and databases, and it also implies additional execution overhead; However, if ORM is implemented as a middleware, there are many opportunities for optimization, And these do not exist in the persistent layer of handwriting. More importantly, the metadata needed to control the transformation needs to be provided and managed; But again, these costs are less than those that maintain handwriting;
What's the use of ORM?--when to use?: 1. Simplify table operation, ORM provides the generation of all SQL statements, the code personnel away from the concept of the database, programmers less access to the underlying SQL, many people can minimize the development of Misoperation 2. If a project is developed, many places need to perform one-to-one, One-to-many table operations, you can try the ORM model, because it can simplify the SQL code, the Many-to-many relationship table operation does not recommend using ORM, execution efficiency will be reduced by a word: ORM let us out of SQL,  But it does not mean that we no longer use SQL, in fact, complex queries and reports I still recommend using SQL such as: Echo $supply->get (5)->books->classname; Automatically get content in supply and books Associations Q: How do you write with SQL? A: First get the value in $supply, and then write SQL through Supplyid as a query criteria to obtain books in classname $result =mysql_query (SELECT * from supply where id=5) $row = Mysql_fetch_array ($result); mysql_query (SELECT * from book where supplyid= $row [Supplyid]); $books =mysql_fetch_array ($result);    3. Database independence: Smooth migration of databases and heterogeneous databases (this seems to be of little use?) 4. Persistence of Entity objects: the corresponding relationship between the data of the relational database and the object.
A depressing point of view: Using ORM in PHP is most useful only to improve development efficiency, so that phper less write-point SQL statements, and Java use Hibernate or the comfort of the ...  reference: ORM Principle-orm objectives and layering http:/ An ORM framework written by/www.cnblogs.com/eugenewu0808/archive/2009/01/05/1368680.html  http://code.google.com/p/ Queryphp/downloads/list Orm's mishap: http://www.cnblogs.com/Barton131420/archive/2007/01/07/613955.html Why do we use ORM?  http://www.cnblogs.com/tansm/archive/2006/06/07/419927.html

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.