was leery to say the least. I have never defined the foreignKey in the
fields array and I've never had a problem. Same with defining the
models. I never work directly on those models ever, so I don't need
them. Same goes for RegistrationLocation and Activity, they do not
have their own model files and yet still work properly. So needless to
say, those solutions did not bear fruit either.
Because there is so much similarity between models that are giving me
the right data and this one. And the fact that this one gives me the
right data when the find is called on itself. I am lead to believe
that the error is in some way I am writing the contain array, however
everything I have read has told me write the array in that manner,
which just adds to my confusion.
On Feb 25, 1:55 pm, John Andersen <j.andersen...@gmail.com> wrote:
> To summarize your relationships/associations between your models, I
> got the following:
> Permit HABTM Activity
> Permit belongsTo RegistrationLocation
> Permit belongsTo User
> Permit belongsTo Leader
>
> Leader hasMany Permit
> Leader belongsTo User
> Leader belongsTo Country
> Leader belongsTo ProvState
>
> Not that I am an expert in CakePHP, but my question is - why don't you
> define the Country and ProvState models? And therein define that
> Country hasMany Leader, and ProvState hasMany Leader.
>
> I assume that the RegistrationLocation and User models have the
> associations/relationships defined to Permit (both) and to Leader
> (User).
>
> Also, when you are using Containable, it is usually a good idea that
> Fields include the foreign keys! At least that is what I have read
> here in the group.
>
> Hope this helps you on the way :)
> John
>
> On Feb 25, 9:05 pm, "Arak Tai'Roth" <nielsen.dus...@gmail.com> wrote:
>
> > I'll post the important parts. My models are slightly bigger then
> > this, but they only contain other associations not related to this,
> > validation, or functions.
>
> > This is Permit.php
>
> > var $hasAndBelongsToMany = array(
> > 'Activity' => array(
> > 'className' => 'Activity',
> > 'joinTable' => 'permits_activities',
> > 'foreignKey' => 'permit_id',
> > 'associationForeignKey' => 'activity_id',
> > 'unique' => true,
> > 'fields' => array(
> > 'Activity.activity_name'
> > )
> > )
> > );
>
> > var $belongsTo = array(
> > 'RegistrationLocation' => array(
> > 'className' => 'RegistrationLocation',
> > 'foreignKey' => 'registration_location_id',
> > 'fields' => array(
> > 'RegistrationLocation.registration_location_name'
> > )
> > ),
> > 'User' => array(
> > 'className' => 'User',
> > 'foreignKey' => 'user_id',
> > 'fields' => array(
> > 'User.first_name', 'User.last_name'
> > )
> > ),
> > 'Leader' => array(
> > 'className' => 'Leader',
> > 'foreignKey' => 'leader_id',
> > 'fields' => array(
> > 'Leader.first_name', 'Leader.last_name', 'Leader.address',
> > 'Leader.city', 'Leader.prov_state_id', 'Leader.country_id',
> > 'Leader.postal_code', 'Leader.phone_number',
> > 'Leader.emergency_phone_number'
> > )
> > )
> > );
>
> > And this Leader.php
>
> > var $hasMany = array(
> > 'Permit' => array(
> > 'className' => 'Permit',
> > 'foreign_key' => 'leader_id',
> > 'fields' => array(
> > 'Permit.id', 'Permit.date_in', 'Permit.date_out',
> > 'Permit.group_size', 'Permit.deregistration', 'Permit.checked_in'
> > )
> > )
> > );
>
> > var $belongsTo = array(
> > 'User' => array(
> > 'className' => 'User',
> > 'foreignKey' => 'user_id'
> > ),
> > 'Country' => array(
> > 'className' => 'Country',
> > 'foreignKey' => 'country_id',
> > 'fields' => array(
> > 'Country.printable_name'
> > )
> > ),
> > 'ProvState' => array(
> > 'className' => 'ProvState',
> > 'foreignKey' => 'prov_state_id',
> > 'fields' => array(
> > 'ProvState.name'
> > )
> > )
> > );
>
> > I have nothing for Country or ProvState.
>
> [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