Welcome Guest, Not a member yet? Register   Sign In
[Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition)

[eluser]monkeyhouse[/eluser]
Wow thanks for the quick response.

The error it was stopping on was the database error. You were correct that I do have the relationship validation rule required. With the existing lib it worked if I turned that rule off. I dropped in the new file, turned the rule back on and everything works great :-)

Thanks!

[eluser]Benedikt[/eluser]
Hi,
I have a few questions about the usage of this ORM extension. I hope somebody can help me out here:

1) I have model "Photo" and a model "Album". In Photo I set "Has One Album", in Album I set "Has many Photos". Now let's assume I save the current photo in relation to Album A. In a next step I want to "move" the photo to Album B. Now I read the photo-object and save it again, this time with Album B as relation. Would this update the "1-to-1" relation automatically?

2) I have a user and I have a group. Now I want to define one user of the group as "Head of the group". I added a column "head_of_group" in the relation/join-table (join_group_user). How can I save and query this field? E.g. I want to read the Head of a special group or want the group where the user is the head?

Sorry for the complex questions, but I want to figure this out to see if it's suitable for my project.

Thanks a lot for help!!!

[eluser]OverZealous[/eluser]
@Benedikt
1) Has One relationships are automatically updated. More on relationship types. It works even better (less queries) if you use In-Table Foreign Keys.

2) Two ways. One is to use join fields, which is probably the best, the other is to create a second relationship from group to users just to track who's the head.

As I mentioned in the email, a lot of your questions are answered simply by reading the documentation. It is fairly extensive, and includes many examples. It even includes a functional (if minimal) example application you can set up and walk through.

[eluser]lsemel[/eluser]
I'd like to transparently transform fields when a DMZ row is loaded or saved. Is there a way to do this? Examples:

1) Whenever I load a row, I want to transparently the mysql formatted date into a unixtime on a particular field, and whenever I save the row, I want to change it back, transparently.

2) Whenever I save a row, I want a certain field automatically changed to lowercase before saving.

3) Whenever I load a row containing the fields 'name' and 'id', I want to create a new field path' which is $name.'/'.$id. I don't want this field to be saved if I save the row, since it doesn't actually exist in the database. I know I can easily create a method that does this, but why should the people using my views have to know they need to use $mymodel->path() when all the other fields are like $mymodel->name, with no parenthesis?

I feel like either or all of these could be done with DMZ validators, but not sure exactly how.

[eluser]OverZealous[/eluser]
I'm not going to bother linking. Please read the manual, and look at validation (for converting before saving) and get_rules (for converting after queries).

Your first two examples are explicitly defined within the docs! The third is a trivial variation on the theme, and there are already built-in modifiers for that one.

[eluser]lsemel[/eluser]
This is possibly a very basic question. I have lists and creators. Each list has one creator.

Is there a more efficient way to do this? Can I get all the lists and populate the creator objects in one query?

$lists = new List();
$lists->get();
foreach($lists as $list) {
$list->creator->get();
}

... later, in a view ...

foreach($lists as $list) {
print $list->name . " created by " . $list->creator->name;
}

[eluser]OverZealous[/eluser]
PLEASE, read the manual before posting.

This is actually answered on the front page of the manual.

[eluser]lsemel[/eluser]
I had seen the page about include_related and thoroughly went through the "get", "get by" and "get (advanced)" sections. Include_related adds extra prefixed columns to an object. I am trying to figure out if I can have the related object itself instantiated and populated along with the main object, in one query. That didn't seem to be an option for include_related, and I didn't see anything else referencing it. Not sure what you were referring to on the front page of the manual.

Maybe a larger FAQ, or reorganizing this forum as separate posts rather than one long thread, would reduce the burden of answering questions which, to you as the author, are extremely obvious, but may not be as obvious to new users of this otherwise excellent package.

[eluser]OverZealous[/eluser]
The front page has this:
Quote:The ability to include data from singularly related objects.
Which links to the include_related page.

DMZ does not automatically pre-populate sub-objects. The include_related method works really well to fill in this regard. You did not mention anywhere in your question that you wanted it to fill in the related objects, or that you have looked into include_related. You asked how to make it more efficient, which is fairly clearly exampled in the docs.

The FAQ covers most of the common problems. I think the documentation fairly thorough, especially for a one-developer, free library. I spent over 40 hours rewriting the original DataMapper documentation to bring it up-to-date for DMZ, and have spent a lot of time keeping it up-to-date as new features are added.

Update: I am aware that there are quite a few broken links in the current docs. I did some re-arranging for the last update, and haven't had time to fix them.

I have been planning on starting a new thread as of the next new version, and I will probably create new threads for each version after that. But that won't solve anything, it will in fact make it less likely new users will read the old threads, which are already full of the same questions being repeated.

I will not be able to release another version of DMZ, however, for a while yet. I have my own projects I need to finish.

[eluser]lsemel[/eluser]
I think it is very good, especially given that it's built by one person. It's saved a lot of time on the project I'm working on.

It's too bad a lot of people are asking the same stuff over and over. It is clearly wasting your time. I think if it were on its own forum with separate threads, and thus more easily searched, people would not need to ask the same questions. It's very hard to search these posts, since they're all in one thread, especially since the individual questions don't have subjects you can search on. I'd recommend a Stack Exchange site (http://stackexchange.com/) except it's $129/month - but moving the discussion to a something like a free Google Group would probably solve this just as well, and save you time you can use on your other projects.




Theme © iAndrew 2016 - Forum software by © MyBB