10.04.2018 Views

Doctrine_manual-1-2-en

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 1: Introduction 13<br />

Chapter 1<br />

Introduction<br />

Code Examples<br />

The text in this book contains lots of PHP code examples. All starting and <strong>en</strong>ding PHP tags<br />

have be<strong>en</strong> removed to reduce the l<strong>en</strong>gth of the book. Be sure to include the PHP tags wh<strong>en</strong><br />

you copy and paste the examples.<br />

What is <strong>Doctrine</strong>?<br />

<strong>Doctrine</strong> is an object relational mapper (ORM) for PHP 5.2.3+ that sits on top of a powerful<br />

database abstraction layer (DBAL). One of its key features is the option to write database<br />

queries in a proprietary object ori<strong>en</strong>ted SQL dialect called <strong>Doctrine</strong> Query Language (DQL),<br />

inspired by Hibernates HQL. This provides developers with a powerful alternative to SQL that<br />

maintains flexibility without requiring unnecessary code duplication.<br />

What is an ORM?<br />

Object relational mapping is a technique used in programming languages wh<strong>en</strong> dealing with<br />

databases for translating incompatible data types in relational databases. This ess<strong>en</strong>tially<br />

allows for us to have a "virtual object database," that can be used from the programming<br />

language. Lots of free and commercial packages exist that allow this but sometimes<br />

developers chose to create their own ORM.<br />

What is the Problem?<br />

We are faced with many problems wh<strong>en</strong> building web applications. Instead of trying to<br />

explain it all it is best to read what Wikipedia has to say about object relational mappers.<br />

Pulled from Wikipedia 1 :<br />

Data managem<strong>en</strong>t tasks in object-ori<strong>en</strong>ted (OO) programming are typically implem<strong>en</strong>ted by<br />

manipulating objects, which are almost always non-scalar values. For example, consider an<br />

address book <strong>en</strong>try that repres<strong>en</strong>ts a single person along with zero or more phone numbers<br />

and zero or more addresses. This could be modeled in an object-ori<strong>en</strong>ted implem<strong>en</strong>tation by a<br />

1. http://<strong>en</strong>.wikipedia.org/wiki/Object-relational_mapping<br />

----------------- Brought to you by

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!