as me from what I can tell, except you didn't specify fields grabbed
in your models. I removed that info in mine, but that didn't change
anything.
I'm not sure, but I have a feeling this all relates to the fact that
contain doesn't seem to be grabbing anything that is two levels deep,
it grabs a model fine and it's associations fine, but it is not
grabbing the associations of the associations. This seems like a
recursive problem to me, but I tried setting the recursive property of
the model and that didn't help, but I might have done it wrong, I
haven't been able to find an example of doing it.
On Feb 28, 3:29 am, John Andersen <j.andersen...@gmail.com> wrote:
> Ok, have recreated your situation - and it just works!
>
> My result:
> [result]
> Array
> (
> [Permit] => Array
> (
> [id] => 1
> [created] => 2010-02-28 10:55:16
> [user_id] => 1
> [leader_id] => 1
> [registration_location_id] => 1
> )
> [User] => Array
> (
> [id] => 1
> [name] => user1
> )
> [Leader] => Array
> (
> [id] => 1
> [name] => leader 1
> [created] => 2010-02-27 10:53:57
> [country_id] => 1
> [prov_state_id] => 1
> [user_id] => 1
> [Country] => Array
> (
> [id] => 1
> [name] => country 1
> )
> [ProvState] => Array
> (
> [id] => 1
> [name] => prov state 1
> )
> )
> [RegistrationLocation] => Array
> (
> [id] => 1
> [name] => location 1
> )
> )
> [/result]
>
> based on the Permit controllers find:
> [code]
> $permits = $this->Permit->find(
> 'first', array(
> 'conditions' => array(
> 'Permit.id' => 1
> ),
> 'contain' => array(
> 'Leader' => array('Country','ProvState'),
> 'User',
> 'RegistrationLocation'
> )
> )
> );
> debug($permits);
> [/code]
>
> Using only the following models:
> user.php
> leader.php
> permit.php
>
> Thus RegistrationLocation, Country and ProvState uses the AppModel as
> base.
>
> My models are defined as:
> [UserModel]
> class User extends AppModel {
> var $name = 'User';
> var $hasMany = array('Leader','Permit');}
>
> [/UserModel]
>
> [LeaderModel]
> class Leader extends AppModel {
> var $name = 'Leader';
> var $hasMany = array('Permit');
> var $belongsTo = array('User','Country','ProvState');}
>
> [/LeaderModel]
>
> [PermitModel]
> class Permit extends AppModel {
> var $name = 'Permit';
> var $belongsTo = array('User','Leader','RegistrationLocation');}
>
> [/PermitModel]
>
> Please compare with your situation, maybe the above will help you on
> the way.
> Enjoy,
> John
> On Feb 28, 10:46 am, John Andersen <j.andersen...@gmail.com> wrote:
>
> > Could be! I am trying to recreate your situation here at my place, to
> > confirm that I too can't retrieve the Country.
> > Will be back shortly :)
> > John
>
> > On Feb 28, 10:40 am, "Arak Tai'Roth" <nielsen.dus...@gmail.com> wrote:
>
> > > This is the only thing that is even remotely relevant in app_model:
>
> > > var $actsAs = array(
> > > 'Containable'
> > > );
>
> > > Other then that, there are only 2 functions, one for validating phone
> > > numbers, and one for changing dates to a format I want.
>
> > > Like I have said previously, this is all working when I do the search
> > > on the model Leader, just not when I do the search on the model Permit
> > > and have a contain with Leader in it, and then a contain with the
> > > country data.
>
> > > So because it works for something, just not quite as deep, I have a
> > > feeling we are looking in the entirely wrong area.
>
> > [snip]
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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment