[eluser]titoneo[/eluser]
Hello everyone!
This is my first post in this forum and since I started to learn Code Igniter I have to say I love it!
I was reading about the DataMapper documentation because I need a ORM for my project.
I need to create an object structure that can be saved in the session to save later in DB.
Code:
Project
|
|-Name
|-Date
|-Members (Related)
|
|-House (Related)
|
|-Chairs (Related)
|-....
....
In others ORM's (like JPA in Java) you can do something like this (the syntax is not exactly like that but I think they also understood):
Code:
//Creation in first controller
house = new House();
house.addChair(new Chair('chair1'));
house.addChair(new Chair('chair2'));
project = new Project();
project.setHouse(house);
... //other stuff to set
session['project'] = project;
//Update in second controller
project = session['project'];
project.getHouse().addChair(new Chair('chair3'));
session['project'] = project;
//Saving in third controller
project = session['project'];
project.save();
DataMapper I think is pretty good, but not find a way to keep all the structure in a simple object in the session, update and save in the end with a simple call. Additionally, with DataMapper, when you have to save a one to many relation you have to think about which object references to the other in database (think of tables) and I think it is just the opposite of how objects work (think of objects), isn't it?
Thanks