Welcome Guest, Not a member yet? Register   Sign In
DMZ 1.7.1 (DataMapper OverZealous Edition)
#41

[eluser]Mareshal[/eluser]
@OverZealous, what's your guide when adding new features to DMZ? Guide I mean, which other ORM ?
#42

[eluser]OverZealous[/eluser]
@rideearthtom
You can already do that: just include the "join_<name>" column names when using to_json. You should always specify the column names, anyway, so you know exactly what is being sent.

As for your question above, check this post for some pointers. That's basically the only way to make it work.

@Mareshal
Not sure exactly what you mean. I don't build DMZ based on other, existing ORMs. stensi based his original design on someone who based their design on (I assume) the RoR DataMapper pattern.

I based my changes on adding features that I find useful, or others have requested many times. I'm not building toward a goal, per se, but rather, building up. At this point, feature-wise, I'm trying my best to not add more to the base library, as it is already very, very big. The reason 1.7 included so many new core features is that all but a few of them (namely, the paging functions) required changes in the library itself to work. And I figured the paging tools were useful enough that I should have them as part of the core.

I guess that I've been working with ideas for my own ORM library for a long time. When I was a Java developer, the big ORM was Hibernate. But I could never get started, because it felt like you needed a couple hundred XML files to get it working. So, to keep from writing SQL code, I have to write a ton of XML code. And still write a ton of Java to glue everything... Yeah, that's soooo much better. Smile (A lot has changed since then, I know.)

Anyway, when I started using DataMapper, I needed certain things (self-relationships, multiple relationships, join table fields, etc). When stensi was unable to work on DM for a while, I took over (I did discuss this with him some), with DMZ.

Hoepfully that helps explain somewhat.
#43

[eluser]Mareshal[/eluser]
I didn't say you build DMZ on other ORMs. But you must implement some methods which are already made in other big projects like doctrine.
#44

[eluser]OverZealous[/eluser]
@Mareshal
I still don't understand the question, but the answer is, no, I don't. I don't use Doctrine. I don't have it installed. I use DMZ. ;-)
#45

[eluser]Unknown[/eluser]
Hi,

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'
                    )        
            );  
        
    var $has_many = array(
            'subscriber' => array(
                'class'=>'user',
                'other_field'=>'subscribedevent'
            )
            );

Code:
class User extends DataMapper {
        
    var $has_many = array(        
        'subscribedevent' => array(
            'class' => 'event',
            'other_field' => 'subscriber'
        ),
        'ownedevent'=>array(
            'class'=>'event',
            'other_field'=>'owner'
        )

    
    );

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?

Thank you.
#46

[eluser]Frank Liu[/eluser]
DMZ's main library file contains spl_auto_load function, which is not supported until PHP 5.1.2. So you may want to change server requirement to reflect this?

Anyway, can I just remove the spl_auto_load statement and find another way to load the files? Do you have a recommended way to deal with this problem? I am using php 5.0.0.
#47

[eluser]Mareshal[/eluser]
I really don't understand why some people use some buggy versions of PHP. I like to use all the time the latest codes/software . I think a stable code begins with RC...and PHP is already 5.3.1 stable
#48

[eluser]Frank Liu[/eluser]
I think we all would like that. But that's how my company works. I submit a request for an upgrade; they told me it will be done by the end of next quarter...

Life sucks here. We are using a 10yo solaris box and a version 9 oracle. Apparently the upgrade to php5.0.0 was already a stretch (and oci8 is partially broken as well).

!!!

anyway.
#49

[eluser]Mareshal[/eluser]
Finally made it to work with CI 2.0 Big Grin, but is slower than CI's active record

DMZ => 0.0136ms
ActiveRecord => 0.0034ms
Mysql_query() => 0.0012ms

Is this normal?

And is there an option to build database from models?
#50

[eluser]OverZealous[/eluser]
[quote author="foonk" date="1269037776"]
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.
[/quote]
You are welcome! I appreciate the support.

Quote:I am running into a problem with advanced relationships.

Your code looks correct from here. :-S

One thing is to make sure that the $owner object has been loaded correctly! It's an easy mistake to make.

Also, is it possible you have the $has_one relationship defined both as an in-table foreign key AND on your join table? You only need one.
Code:
TABLE events
id ... owner_id // only one of these should exist

TABLE events_users
id ... owner_id // only one of these should exist


If not that, then, one thing you can try is removing owner_id and ownedevent_id from the events_users table, and adding owner_id to the events table.

While it should work just fine storing the owner relationship on your events_users table, you will also see a significant performance gain by using an ITFK, especially with DMZ 1.7, as it optimizes queries to take advantage of them.


Don't forget to go through the steps listed in the troubleshooting guide, especially the part about checking your queries.




Theme © iAndrew 2016 - Forum software by © MyBB