Doctrine (PHP)

Doctrine (PHP)

See also DataEase, whose query language is also called DQL.

Doctrine
Doctrine logo white.png
Stable release 2.1.2 / August 29, 2011; 54 days ago (2011-08-29)
Development status Active
Written in PHP
Operating system Cross-platform
Type Object-relational mapping framework
License GNU Lesser General Public License
Website www.doctrine-project.org

Doctrine is an object-relational mapper (ORM) for PHP that provides persistence for PHP objects. It sits on top of a database abstraction layer. 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).

Contents

Usage demonstration

Doctrine 1.x follows the active record pattern for working with data, where a class corresponds with a database table. For instance, if a programmer wanted to create a new "User" object in a database, he/she would no longer need to write SQL queries, but instead could use the following PHP code:

 $user = new User();
 $user->name = "john";
 $user->password = "doe";
 $user->save();
 echo "The user with id $user->id has been saved.";

Object-related functionality can be added to the objects themselves, instead of being spread around the application. This can improve the ease of maintenance of the software project.

In Doctrine 2.x, the latest release of Doctrine, the entities no longer have to extend a base Active Record class. Instead you just persist them by passing them to the so called Entity Manager:

 $user = new User();
 $user->name = "john";
 $user->password = "doe";
 $em->persist($user);
 echo "The user with id $user->id has been saved.";

Features

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 hierarchical (tree-structured) data;
  • 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;
  • model behaviors (sluggable, timestampable, nested set, internationalization, audit log, search index);
  • 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.

History

Doctrine was started by Konsta Vesterinen, also known as zYne-. The project's initial commit was made on April 13, 2006 to the svn repository.[1] As the project became more mature, the adoption began to pick up. Before long, the community was active and development was receiving regular contributions, among others from the Google Summer of Code project.

Doctrine 1.0.0 was released on September 1, 2008.[2]

The first stable version of Doctrine 2.0 was released on December 22, 2010, after 2.5 years of dedicated development starting in early 2008.[3]

Influences

Doctrine has been influenced by dozens of projects and many different people. The largest influences have been the Java ORM Hibernate and ActiveRecord from Ruby on Rails. Both of these ORM solutions have implemented a fully featured solution in the Java and Ruby languages. The purpose of the Doctrine project is to build an equally powerful solution for the PHP language.

Community

See also

References

External links


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Doctrine (PHP) — Doctrine Aktuelle Version 2.1.2 (29. August 2011) Programmier­sprache PHP Kategorie Framework, Objektrelationaler Mapper Lizenz GNU Lesser General Public License …   Deutsch Wikipedia

  • Doctrine (PHP) — Doctrine Тип Написана на ОС Кроссплатформенное программное обеспечение Версия 1.0.4 Шаблон:Release date Лицензия GNU Lesser General Public License Сайт …   Википедия

  • Doctrine — steht für Doctrine (PHP), Framework zur objektrelationalen Abbildung The Anti Doctrine, deutsche Band Fairness Doctrine, Rundfunkrichtline der USA Doctrine classique, Regeldrama der französischen Klassik Siehe auch Doktrin …   Deutsch Wikipedia

  • Doctrine — For the PHP object relational mapping framework, see Doctrine (PHP). Doctrine (Latin: doctrina) is a codification of beliefs or a body of teachings or instructions, taught principles or positions, as the body of teachings in a branch of knowledge …   Wikipedia

  • Doctrine — Тип ORM Написана на PHP Операционная система кроссплатформенный Последняя версия 2.2.0 (29 января 2012) Лицензия GNU Lesser General Public License Сайт …   Википедия

  • Doctrine de foi — Doctrine Cette page d’homonymie répertorie les différents sujets et articles partageant un même nom …   Wikipédia en Français

  • Doctrine officielle — Doctrine Cette page d’homonymie répertorie les différents sujets et articles partageant un même nom …   Wikipédia en Français

  • Doctrine politique — Doctrine Cette page d’homonymie répertorie les différents sujets et articles partageant un même nom …   Wikipédia en Français

  • Doctrine religieuse — Doctrine Cette page d’homonymie répertorie les différents sujets et articles partageant un même nom …   Wikipédia en Français

  • Doctrine traditionnelle — Doctrine Cette page d’homonymie répertorie les différents sujets et articles partageant un même nom …   Wikipédia en Français

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”