Well PalDB is yet another framework for PHP. PalDb is a fast and powerful database abstraction layer and ORM. While it is not as full-featured as Doctrine or Propel, it comes quite close when you use it with MySQL. It shares Pal’s paradigms of simplicity and elegance.

Features

You can use PalDb in two ways:

1) As a simple but powerful database abstraction layer. For this, just use the following classes:

  • Db – A class representing database connections. Use this to create and re-use connections to various databases.
  • DbQuery – A class representing database queries. You can string its methods along to have something like $db->select(…)->join(…)->where(…)->execute()->fetchAll()
  • DbE – A database expression. This is a great way to build up database expressions that won’t be escaped as if they were strings. (Most other database frameworks don’t have this feature.) In fact, DbQuery objects extend DbE objects, and you can use this to easily build subqueries.
  • DbResult – This wraps a result set, and allows you to fetch rows from it, among other things.

2) As an abstraction layer as well as an ORM. For this, use the classes above together with the following classes:

  • DbRow – A powerful class that implements ORM. Allows intelligent creating, retrieving, updating and deleting of records (“rows”). Has hooks for events such as beforeSet, beforeSave, beforeSaveExecute. Useful for implementing stuff like memcache support later, because everything is in one place. Also takes care of stuff like prefixing field names.
  • DbRelation – a very flexible way of specifying relationships between rows. So you can specify a relationship like this:
$this->hasOne('email', 'Email', 'u',
    new DbRelation('user AS u', array('e.address' => 'u.email_address'),
    'email AS e'));

And then you can retrieve related rows simply by calling $user->get_email(). PalDb takes care of the rest.

Implementation

PalDb is currently implemented using PDO (Php Data Object) . It is possible to build other drivers for it, but at the moment it is simply geared toward a PHP+MySQL combo.

cheers !!

Realin !

Share this post: