PHP ORM

OBJECT-RELATIONAL MAPPING IN PHP

0  0 2015-04-10 01:18:37

First of all The Big Question is What Is ORM?
And The answer for it is as follows:                                    
Object-relational mapping (ORM, O/RM, and O/R mapping) in computer science is a programming technique for converting data between incompatible type systems in object-oriented programming languages. This creates, in effect, a "virtual object database" that can be used from within the programming language. There are both free and commercial packages available that perform object-relational mapping, although some programmers opt to create their own ORM tools.
In object-oriented programming, data management tasks act on object-oriented (OO) objects that are almost always non-scalar values.

For example, consider an address book entry that represents a single person along with zero or more phone numbers and zero or more addresses. This could be modeled in an object-oriented implementation by a "Person object" with attributes/fields to hold each data item that the entry comprises: the person's name, a list of phone numbers, and a list of addresses. The list of phone numbers would itself contain "PhoneNumber objects" and so on. The address book entry is treated as a single object by the programming language (it can be referenced by a single variable containing a pointer to the object, for instance). Various methods can be associated with the object, such as a method to return the preferred phone number, the home address, and so on.

Orm`s To look for in PHP
1)    Propel
2)    Doctrine

What is Propel exactly?
Propel is an open-source Object-Relational Mapping (ORM) for SQL-Databases in PHP 5.4. It allows you to access your database using a set of objects, providing a simple API for storing and retrieving data.
Additional to its ORM capabilities it does provide a query-builder, database schema migration, reverse engineering of existing database and much more.
Why Propel?
Propel gives you, the web application developer, the tools to work with databases in the same way you work with other classes and objects in PHP without writing SQL.
•    Propel is blazing fast
•    Query-Builder
•    IDE friendly thanks to code-generation
•    Generation of methods for all columns and relations
•    Database schema migration
•    Schema reverse engineering
•    Customizable
•    Well documented
•    Propel comes with common 'behaviors'
 
2)Doctrine

The Doctrine Project (or Doctrine) is a set of PHP libraries primarily focused on providing persistence services and related functionality. Its prize projects are an Object Relational Mapper (ORM) and the Database Abstraction Layer it is built on top of.
One of Doctrine's key features is the option to write database queries in a proprietary object oriented SQL dialect called Doctrine Query Language (DQL).
One feature of Doctrine is the low level of configuration that is needed to start a project. Doctrine can generate object classes from an existing database, and the programmer can then specify relations and add custom functionality to the generated classes. There is no need to generate or maintain complex XML database schemas, as seen in many other frameworks.
Another key feature of Doctrine is the ability to optionally write database queries in an OO (object oriented) SQL dialect called DQL (Doctrine Query Language) inspired by Hibernate's HQL. Alternately, the QueryBuilder class (Doctrine_Query in Doctrine 1.x) allows one to construct queries through a fluent interface. These interfaces provide developers with powerful alternatives to SQL which maintain flexibility and still allow for switching of database back-ends, without requiring any code duplication.
Writing queries explicitly however is not always necessary, as Doctrine performs joins and fetches related objects automatically. Small projects can be easily constructed without writing queries.
Other notable features of Doctrine are:
•    support for hooks (methods which can validate or modify database input and output) and event listeners to structure business-related logic;
•    column aggregation inheritance (similar objects can be stored in one database table, with one type-column specifying the subtype of the particular object - the correct subclass is    always returned when a query is done);
•    a caching framework, making use of several backends such as memcached, SQLite or APC;
•    ACID transactions;
•    database migrations;
•    a "compile" function to combine many PHP files of the framework into one, to avoid the performance hit usually incurred by including the many PHP files of a framework.

 

Comments (0)

Post Your Comments

Headquarter



Hong Kong Office



Find Us On

Ziuby
Ziuby