My apps…

Space Harvest Begin

All-Seeing Interactive is a tiny web design and software company based in London, UK.

Saturday 3 January 2009

Introducing FuzzyRecord: A Rails-like Active record implementation for PHP 5.3

FuzzyRecord is an Object-Relational-Mapping (ORM) system for PHP applications, based on the Active record design pattern, most famously used in Ruby On Rails.

It makes use of the new Late Static Binding features in PHP 5.3, which basically makes static methods a lot more useful. As a result, it has a clean API not dissimilar from Rails:

$user = User::find_by_email("");
$user = User::find_by_first_name_and_last_name("Ben","Copsey");
$articles = Article::find_all_by_date_greater_than("2008-07-07");
$users = User::find(
  "first_name" => "Ben", 
  "start_from" => 10,
  "order_by" => "last_name",
  "sort" => "ascending", 
  "where" => "status = 'validated'"
$photos = $user->photos;
$photos = Photo::find_all();
$user->photos = $photos;
if (!$user->save()) {

Along with a nice API for querying your data, it supports:

  • validating properties (eg: max / min length, is an email address etc)
  • relationships with cascade update / delete
  • integer, natural and composite primary keys
  • explicit and automatic transactions
  • Data caching to reduce database load, including Memcached support

It currently supports MySQL databases, but the database access layer is based on PDO, and I expect to add Postgres support soon.

Documentation is available here:

You can grab the latest source with git:

$ git clone git://

Or just get a tarball here:

Posted by Ben @ 3:37 PM