On Mon, Mar 18, 2013 at 12:40 PM, Jerome Walitzek
<jerome.walitzek@t-online.de> wrote:
> Hi there,
>
> i have a problem with INNER JOIN.
>
> Models
> Job
> User
> UsersEvent
What are the associations between models? Do you also have an Event
model? I ask because that last one looks like a join model between
User & Event. (Although for Cake the table would conventionally be
named events_users -- models are alphabetical.)
You can use joins for hasOne and belongsTo assoc. One workaround is to
unbind the normal assoc. and temporarily bind on another.
> In my Job View i would like to get all users which are assigned to an event.
> I only get successfully the IDs from UsersEvent but not the names from the
> User Model.
>
> In principle I would like to do following:
> SELECT A.`id`,(CONCAT(A.vorname, ' ',A.nachname)) AS name FROM users AS A
> INNER JOIN users_events AS U ON A.id = U.user_id WHERE U.event_id = 2
>
> But how i write it cake like ?
>
> When i try it with
> $this->Job->query("SELECT A.`id`,(CONCAT(A.vorname, ' ',A.nachname)) AS name
> FROM users AS A INNER JOIN users_events AS U ON A.id = U.user_id WHERE
> U.event_id = 2");
> i get the complete array in my select field and can´t select a name.
>
> Thanks for help
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cake-php+unsubscribe@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Monday, March 18, 2013
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment