> I got one Checklist model which belongsTo a User, Language,
> OperatingSystem, Product.
> My User hasMany Checklist.
>
> Now I want to fetch all User related checklists through the
> UsersController. So when I do a $this->User->find('first', array
> ('conditions' => array('id' => $id))); I get only the checklists
> language_id's, operating_system_id's ...
> how do i get the Language.name fields?
>

You could increase your recursive level, i.e.

$this->User->recursive=2;

but I would not recommend to do so, as you will get all other
associated models as well and this increases load on the DB.

Alternatively you could write a method in your Location model that
returns your Location.name for a given id, e.g.

function getLocationName($id) {
   return ($this->field('name', array('id' =>$id)));
}

and loop through your initial results array. Maybe this isn't the
optimal solution either, if you have to do a lot of loops.
It could be more efficient to just keep on using the id's in the
controller and get the names just in the views (using a helper) - but
this depends on your db and application structure.

Cheers,
tobi_one
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to