Pork.dbObject is a tiny (500 lines) but powerful hot-pluggable OR-mapper/Active Record implementation for PHP5. It automatically recognizes different types of relations in your database by matching primary keys and takes care of most of your SQL queries.