Hi,
I suggest that you use Containable behavior:
http://book.cakephp.org/view/474/Containable
Using Containable instead of recursive gives you more control over
what is returned in your queries. I would suggest putting Containable
in your AppModel and setting recursive to -1. I do this:
Class AppModel extends Model {
var $actAs = array('Containable'); // And of course your other
behaviors
var $recursive = -1;
}
Then you're set. So if you want to find the Images associated with
your Properties, you'd do something like this:
$this->Property->find('all', array('contain' => array('Image')));
Or, if you're paginating, just set 'contain' as one of the paginate
options
$this->paginate = array('contain' => array('Image'));
$properties = $this->paginate();
- Jamie
On Oct 20, 8:18 am, ilcaduceo <[email protected]> wrote:
> Hi, I have two models
>
> Properties HasMany Images
> Images BelongsTo Properties
>
> In the index controller method I have this code:
>
> $this->Property->recursive = 0;
> $this->set('properties', $this->paginate(null, $filters));
>
> But in the array $properties, result of paginate in the view, there
> aren't associated model Image...
>
> How can I have the same effect of: this->Property->find('all'); ?
>
> Thanks and sorry for my english ;)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---