Welcome Guest, Not a member yet? Register   Sign In
DMLite ORM for CI3
#1
Heart 
(This post was last modified: 06-04-2015, 07:35 AM by Avram.)

Hello everyone!

I'm sure many of you have used DataMapper ORM (by WanWizard), but as you may have noticed, it is not being developed for a while now. Even its github/bitbucket repositores are removed and you can't download it anymore, so it's most likely dead project now Sad

Therefore, I have started working on my own ORM named "DMLite ORM" (from "DataMapper Lite"). It is in its very early stage, I've been literally working on this for the past 3-4 days only, but it already can be used in (very) simple projects. It is not (yet) thoroughly tested in a real project but I've already started making one using this ORM. I have no idea how it will behave in real world environment.

No code from the old DataMapper is used in DMLite (except the functions from the inflector helper), although I've borrowed some concepts and function names to make it as compatible as possible. My goal is to make such ORM that you can switch from CI2+DataMapper to CI3+DMLite without having to rewrite everything. But do note that this will most likely never be a drop-in replacement for the old DataMapper. At least not without help from more experienced users.

Contrary to original DataMapper which was a CodeIgniter library, this is simply extended core Model (CI_Model). Your models must extend the MY_Model class (which is the DMLite ORM class).

I have started writing documentation as a Github wiki, but as every programmer, I hate writing it. Smile Those familiar with the old DataMapper should be able to easily jump in and start using it, others will have to wait for me to write some docs (which I hope I will do in the following days).

Example of usage:

PHP Code:
<?php
/* CI controller code */

//create author
$author = new Author();
$author->name "Friedrich Nietzsche";
$author->dob 1844;
$author->save();

//create book and save it along with it's author
$book = new Book();
$book->title "Also sprach Zarathustra"  
$book
->isbn 9789562919760;
$book->year 1883;
$book->save(array($author));

?>

Again, please don't be harsh on me if something is not working (as expected) - this is very early version of the code, just a couple of days of work has been invested in this project, but I'd like to make something useful out of it.

Get it here: https://github.com/avramovic/DMLite-ORM
Reply
#2

(This post was last modified: 06-04-2015, 08:20 AM by ivantcholakov.)

@Avram
Can you post an unofficial link form where I could download the latest DataMapper?

Edit: IMO it would be better DataMapper to be revitalized with keeping backward compatibility.
Reply
#3

I know it would be better but it would also take forever, at least for me, to understand it's code. It's huuuuge! And it already requires hacking CI's index.php which I do not like.

If you can please try my ORM and let me know what do you think about it? Smile Of course, I still have alot of work going through old DM's documentation and recreating most of the functions to work in similar way.

Here's the latest version of the old DM I have downloaded: https://dl.dropboxusercontent.com/u/8445..._1.8.2.zip
Reply
#4

The first thing that scratches my eyes is that you occupy the "My_Model" name. This would make a collision with projects that already use it.

Such project (nevertheless you call it "lite") would require time and efforts. Also, if people are being forced to rewrite completly old Datamapper-based code, they would probably combine CodeIgniter 3 with Doctrine 2 or sort of. This is why I hesitate.
Reply
#5

Quote:The first thing that scratches my eyes is that you occupy the "My_Model" name.

Well I thought it seemed logical to extend MY_Model if we're extending models Smile


Quote:Such project (nevertheless you call it "lite") would require time and efforts. Also, if people are being forced to rewrite completly old Datamapper-based code, they would probably combine CodeIgniter 3 with Doctrine 2 or sort of. This is why I hesitate.

I am aware of that but as I said, I will give my best to make is compatible as possible to the old DM. It would be pretty useless to make something by looking at the old DM and force users to rewrite everything to make it work Smile After all, I'm planning to move some of my projects to CI3 and that's why I need (something like) this.

However, if someone is willing to revive the old DM, I'll gladly throw away everything I have done on this so far Smile
Reply




Theme © iAndrew 2016 - Forum software by © MyBB