you should think that, User *hasMany* Requests, therefore when you query
the User model, the related requests comes in as a *collection*, so
$var['User']['Request']['item'] will not work because ['Request'] is a
collection, an array of rows 'item'
array(
'User' => array(...),
'Request' => array(
0 => array(
'item' => ...,
'price' => ...,
),
1 => array(...)
)
)
In order to work with each individually request you should iterate over the
*collection*
foreach ($var['Request'] as $item) {
echo $item['item'] . ' costs: ' . $item['price'] ;
}
anl
On Tue, Feb 9, 2010 at 8:51 PM, dtirer <[email protected]> wrote:
> Oh and:
> User hasMany Request
> Request belongsTo User
>
> Also, even after the query works, I'm always confused about how to
> reference the data ($variable['User']['Request']['item'], ?? etc)
>
>
> On Feb 9, 2:44 pm, dtirer <[email protected]> wrote:
> > Here' my two Models:
> >
> > User:
> > id
> > email
> > password
> >
> > Request:
> > id
> > user_id
> > item
> >
> > If I have a function in my UsersController, and I HAVE User.id, and I
> > want to RETRIEVE User.email and Request.item, how do I do that with a
> > find()?
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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]<cake-php%[email protected]>For
> more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
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