So the News items should "Belong To" a user. The problem I see is that
you can't seem to define a "local key"?
My code in the News controller should look like this yeah?
var $belongsTo = array('Creator' => array(
'className' => 'User',
'foreignKey' => 'user_id',
'localKey' => 'creator_id',
//can't seem to define this?
),
'Modifier' => array(
'className' => 'User',
'foreignKey' => 'user_id',
'localKey' => 'modifer_id',
//can't seem to define this?
),
);
How can I define the local key?
On Jul 9, 10:02 pm, James K <[EMAIL PROTECTED]> wrote:
> You would need to define a relationship in your news model to the
> user's model via the id set by the behaviour. This will tell cake how
> to pull the related models from a find call on the news model (http://
> book.cakephp.org/view/66/models#associations-linking-models-to-78).
>
> You'll also want to look in the manual for more information on the new
> containable behaviour built into the release candidates of CakePHP 1.2
> for how to narrow down what fields/models you want returned (http://
> book.cakephp.org/view/474/containable)
>
> Good luck,
>
> - James
>
> On Jul 9, 12:26 am, double07 <[EMAIL PROTECTED]> wrote:
>
> > Hi All,
>
> > This seems like a real n00b question, but here goes. I'm working on an
> > app which has articles - in my case news - and users who create/modify
> > the news articles. Now I found this nifty little behaviour
> > -http://blog.loadsys.com/2008/05/02/automagically-setting-user-id-of-r...
> > - which automagically records the user id in the news record when
> > somebody adds or edits a news item. So I've got the user id of the
> > creator/modifier in the news article record... lovely.
>
> > So, how then do I use that id in the creator/modifer to grab say the
> > name/email/username of the user and echo it out in a view? At first I
> > was thinking it would be a relationship, but now I'm thinking I need
> > to do something in the news controller?
>
> > If anyone could point me in the right direct that would be much
> > appreciated. Any examples would be helpful.
>
> > TIA.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---