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

[eluser]Benedikt[/eluser]
No.

The join-table needs to be users_requests (missing s after user, maybe typo).

But besides it should work.
I also have my problems in understanding DM, but the support is not very good. Maybe you want to look at Doctrine.
#12

[eluser]benoa[/eluser]
Yep, typo Wink

I had a look @ Doctrine, and there are surely reasons to choose it over DMZ... But I don't know, I feel like DMZ's more CI-compliant (built by CI users, so its CI-minded, and respects the CI conventions -- for instance, the use of underscores is something I require from an external library). But maybe my arguments just make me look stupid over the forums.

I'll be trying your code then! I'm excited because it is actually much more simpler than I thought! Thanks man Smile
#13

[eluser]Benedikt[/eluser]
It's quite easy, but if you have concrete questions not like "How can I create a model" there is nobody to answer your questions. And in a commercial environment this is too difficult to work with.

If you need an answer which is not covered or at least not clearly explained/mentioned in the docs how you want to find out?

But if you ask how it works the reply is "Read the docs". Yeah, and this is not the way to support users in a community, hm?

Anyway, good luck with DM Smile
#14

[eluser]benoa[/eluser]
I think DMZ is a pretty advanced and powerful tool. Indeed, if the support isn't enough, that's a big concern... On my side, I'll stick with it, and try to get used to it. Doctrine is a great candidate, which surely has more support & docs, though I think I'll learn DMZ faster than Doctrine because I'm used of the CI way of doing things, you know? But hey, YOU've been of great support, right? Wink
#15

[eluser]BrianDHall[/eluser]
[quote author="Benedikt" date="1256147743"]It's quite easy, but if you have concrete questions not like "How can I create a model" there is nobody to answer your questions. And in a commercial environment this is too difficult to work with.

If you need an answer which is not covered or at least not clearly explained/mentioned in the docs how you want to find out?

But if you ask how it works the reply is "Read the docs". Yeah, and this is not the way to support users in a community, hm?

Anyway, good luck with DM Smile[/quote]

I'm sure OverZealous would be happy to work out a consulting relationship to provide paid support for those who prefer not to read manuals. If he isn't, I would Big Grin
#16

[eluser]Benedikt[/eluser]
If the manual would cover the question, then sure a paid consulting is reasonable.

And btw, I dont mind paying for support. I even donate for OSS :-O
#17

[eluser]BrianDHall[/eluser]
OK, now a real question. I'm looking to see if there is a short-hand for what I'm doing.

On a few forms and displays where I have lots of data entry and multiple relationship options to display. So I might have a Listing that needs drop-down boxes populated with propertytype, garagetype, amenities, petpolicy, etc etc. Right now to prep everything I do this:

Code:
$listing->propertype->get();
$listing->garagetype->get();
$listing->amenities->get();
$listing->petpolicy->get();
///...etc, etc

It isn't a big deal, but is there a simple way to do this - like a load_all_related() function or somesuch so I don't have to load up each one individually?

I know about autoload/autopopulate features, but this is limited to just needing to use it in a few places. Its purely an attempt to reduce a few lines of code, but DMZ has so much flashy coolness that I figured I might be very well missing something.
#18

[eluser]Benedikt[/eluser]
I didnt test it yet, but you could try to use a loop maybe?

I think it should work to say sth like this:

Code:
$objects = array( "propertype", "garagetype", "amenities", "petpolicy" );

foreach ( $objects as $relation ) {
   $listing->$relation->get();
}

Maybe you can try this and it works or you can take it at least as a hint for further creativity.

Btw, Im sure this is also covered in some manual somewhere :-p Just kidding.
#19

[eluser]Unknown[/eluser]
Hi there,
i am pretty new to DMZ, however I have some problems I was not able to solve by reading the (good) documentation:

1. creating more complex queries with count:
example: I have a users table and a user_group table(each user belongs to 1 group). I want to show a list of all groups and the appropriate number of users belonging to this group.
I want to use only 1 query (performance reasons: I have thousands of groups)
in SQL this is simple:

SELECT ug.* , count( u.id ) as count
FROM user_groups` ug
LEFT JOIN users u ON ug.id = u.group_id
WHERE mg.user_id = ?
GROUP BY mg.id

How can I do this in DMZ?


2. Delete relation, avoid setting id to NULL
example:
User table and media table with 1:n relation (1 user has many media) by user.id = media.user_id
If I delete a user(eg id=2), all media.user_id will be set to NULL which were 2 before. In SQL:

UPDATE `media` SET `user_id` = NULL WHERE `user_id` = '2'

However I want to completely remove them like this:
DELETE FROM media WHERE `user_id` = '2'


3. Unnecessary SELECT statements:
Before the Query from 2 there is always a

SELECT * FROM `media` LIMIT 1

What purpose is this? Can I switch this off?


Best regards,
Peter
#20

[eluser]bEz[/eluser]
@peterparker2k
Quote:3. Unnecessary SELECT statements:
Before the Query from 2 there is always a

SELECT * FROM `media` LIMIT 1

What purpose is this? Can I switch this off?
Useless for the application (unless CACHED). However, in the realm of an ORM, it is ever so necessary for Datamapper and DMz (it's derivative).

Code:
The first time a model is used on a request, DataMapper connects to the database server and loads in the columns for its table. This can create a few extra queries per page. DMZ also does a fair amount of set up on each class, determining things like relationship fields, tweaking the validation rules, and more. All of this can be cached to a file, which is included directly as PHP code.




Theme © iAndrew 2016 - Forum software by © MyBB