July 6, 2008

Home page: www.doctrine-project.org. Current version: 1.0.2

Doctrine is a PHP ORM for PHP 5.2.3+ that sits on the top of a powerful PHP. One of its key features is the ability to optionally write database queries in an object oriented SQL-dialect called DQL inspired by Hibernates HQL.

This provides web developers with a powerful alternative to SQL that maintains a maximum flexibility without requiring needless code duplication.Doctrine requires PHP 5.2.3+. It doesn’t require any external libraries.

For the database function call abstraction Doctrine uses PDO which comes bundled with the PHP official release that you get from www.php.net.

Doctrine features:

  • Supports: MySQL, SQLite, PostgreSQL, Oracle, Mssql, Firebird and Informix.
  • Supports result caching with Memcache, APC or SQLite.
  • Supports import/export with YAML schemas, SQL scripts or existing database.
  • Has DQL (Doctrine Query Language) it helping users in complex object retrieval.
  • Supports migration functionality. For making a migration process easy.
  • Has integrated searching functionality.


This example illustrates the way of extracting data from the database table.

File structure:

Models/Users.php - user model
Doctrine/ - Doctrine library files
Doctrine.php – Doctrine main file

Example of index.php

// include Dotrine main file
require_once 'Doctrine.php';

// register Doctrine library file loader

// connect to database

// set path to models

// create simple query on DQL
$users = Doctrine_Query::create()->from('Users');

// print result
foreach ($users as $user)
echo $user->email;

Example of Users.php

/** * User model definition. */
class Users extends Doctrine_Record {
/** * Define model metadata. */
public function setTableDefinition() {
'type' => 'integer',
'length' => 11,
'primary' => true,
'autoincrement' => true

'type' => 'string',
'length' => 255,
'default' => '',
'notnull' => true


To get your project underway, simply contact us and an expert will get in touch with you as soon as possible.