I just started using this library and I really like it. I've tried doctrine and ignited record and dmz seems to be exactly what i'm looking for. So far it's been the easiest to use and fastest ORM. Thanks for writing this code.
I am running into a problem with advanced relationships. This is my first codeigniter /dmz app and maybe i'm overlooking something so please bare with me. I've read through the user guide and cant seem to find an answer. Also please forgive me if this is the wrong place in the forum to post this question. This is my first post on ci forums.
I have two models, Event and User. Event is related to User in tow ways. Event has_one owner user and has_many subscriber users. User has_many subscribed events and has_many owned_events.
My models are setup like this:
Code:
class Event extends DataMapper {
var $has_one = array(
'owner' => array(
'class' => 'user',
'other_field' => 'ownedevent'
)
);
I have a join table called events_users with columns: id, subscriber_id, subscribedevent_id, owner_id, ownedevent_id
in my controller, If I call
Code:
$event->save($owner, 'owner');
the relationship does not get saved. But when I call
Code:
$event->save($subscriber,'subscriber');
It does.
Am I doing something wrong? The owner_event relationship saves if I move 'owner' into the $has_many array but event should only be allowed to have one owner. Is this the correct way to do it or is there a way where I can constrain it to a has_one relationship?