I’ve finally managed to get my new Object-Relational-Mapper to a stage where I can release it to the public. It has taken a long time, but finally I also have a complete? manual ready (over 26k words, it was a bit of a pain to write).
RapidDataMapper is both a stand alone Object-Relational-Mapper and a mapper which can be integrated into different frameworks. I have made it CodeIgniter-compatible as a first step, but other frameworks will also follow (when I or someone else has time to create compatibility files, making it officially compatible).
The CodeIgniter specific variant replaces the $this->db object with the main connection object of RapidDataMapper, this to make it easier to use. But you can also skip replacing it (by modding the supplied MY_Loader.php) if you want to be able to use both simultaneously.
RapidDataMapper is based on the DataMapper pattern, and I have taken this to the “extreme” by completely decoupling the objects from the mapper and hiding the mappers behind a proxy object. Compared to IgnitedRecord (my previous ORM), RapidDataMapper does not affect the model, at all. Instead the model is supposed to do what it always has done: fetching and storing data. RapidDataMapper is a tool which is to be used *by* the model to simplify database interaction (it is not strictly so, you can use it in the controller or even in the view, but it “makes more sense” to place all db interaction in a few select files).
A somewhat new idea which I use in RapidDataMapper is the Descriptors. They are objects which describe how the objects should be mapped to the database, which columns that map to properties etc. They can be extended and modified in innumerable ways, making it possible to create your own defaults and override normal behaviour of the mappers.
RapidDataMapper uses an autoloader to load the files, and they are stored in the directory application/data_model/ with the name of the class + .php.
class User_objDescriptor extends Db_Descriptor
$this->setSingular('user'); // this makes the other default adjust themselves, eg. table becomes users
$u = new User_obj(); // the User_obj class is autoloaded
$u->name = 'Martin';
Db::save($u); // here is the "magic" done
$u = Db::find('User_obj', 1);
That was just a very very simple example of the usage of RapidDataMapper, it is capable of a lot more.
RapidDataMapper is extremely configurable but it is still aimed to be easy: It assumes a lot of defaults but you can replace almost any of them. By using a code builder and mapper cache can RapidDataMapper really be rapid: only a few files needs to be loaded once the mapper has been built.
Suggestions and comments are extremely welcome!
(and I’m happy to help people start with it, but check the manual first, it should cover the most of it)