basically, performace.
You get just what you need. With recursive > 1 (in most cases) you get
a lot of unnecessary data.
Also you can specify conditions or fields, etc to related models
impossible to set in recursive. Eg:
$this->Country->contain(array('State' => array(conditions' => array
('State.name' => 'bla bla'))));


On Feb 23, 1:10 pm, Curtis <[email protected]> wrote:
> What are the major differences in using containable vs. recursive?
>
> On Feb 23, 8:50 am, mradosta <[email protected]> wrote:
>
> > 1) Try to respect the naming conventions.
> > 2) Use the containable behavior rather than recursive = 2.
> > 3) Check your data. The code looks ok.
>
> > On Feb 23, 11:13 am, Naren <[email protected]> wrote:
>
> > > I have three models Country, State and City
>
> > > I have defined the relationships in the respective models.
>
> > > class Country extends AppModel
> > > {
> > >     var $name = 'Country';
>
> > >         var $hasMany = array
> > >         (
> > >                 'States' => array (
> > >                         'className'  => 'State',
> > >                         'foreignKey' => 'countries_id'
> > >                 )
> > >         );
>
> > > }
>
> > > class State extends AppModel
> > > {
> > >     var $name = 'State';
>
> > >     var $belongsTo =  array
> > >         (
> > >                 'Country' => array (
> > >                         'className'  => 'Country',
> > >                         'foreignKey' => 'countries_id'
> > >                 ),
> > >         );
>
> > >         var $hasMany = array
> > >         (
> > >                 'Cities' => array (
> > >                         'className'  => 'City',
> > >                         'foreignKey' => 'states_id'
> > >                 ),
> > >         );
>
> > > }
>
> > > class City extends AppModel
> > > {
> > >     var $name = 'City';
>
> > >     var $belongsTo =  array
> > >         (
> > >                 'State' => array (
> > >                         'className'  => 'State',
> > >                         'foreignKey' => 'states_id'
> > >                 ),
> > >         );
>
> > > }
>
> > > In the StatesController, for pagination i have given the following
> > > condition
>
> > >     var $paginate = array(
> > >         'limit' => 20,
> > >         'order' => array(
> > >             'State.name' => 'asc'
> > >         ),
> > >        'recursive' => 2
> > >     );
>
> > > And i call the paginate like this:
> > >                 $states = $this->paginate('State');
>
> > > Still i am not able to get the country columns. Can someone suggest me
> > > what is happening and why the recursive is not loading the country
> > > object. i have tried all the soultions i found on the net. Still not
> > > able to get a solutions for the same. Does this behave differently in
> > > linux and windows??.
>
> > > I have to load the State and City object when i paginate cities also
> > > next. Any solution?? Any solution will be helpful. Thanks.- Hide quoted 
> > > text -
>
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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