select lists, radio buttons, check boxes etc). Each option list can
be associated to one or more models most commonly in a hasMany or
HABTM relationship.
What I want to do is make sure that before an option list item is
deleted that the system makes sure it is not currently related to any
other model. I plan to do this in the beforeDelete function of the
OptionListItem model and would imagine it would be best to do it by
interrogating the hasMany and hasManyAndBelongsTo arrays to check for
any associated models then running count finds on those models
returning false if any records are found.
Is there an easy way for me to traverse the following array (possibly
set::combine or extract) and pull out only the associations where
condition array includes option_list_id = $n, or would I have to loop
through the array to achieve this?
var $hasMany = array(
'AgencyStatus' => array(
'className' => 'Agency',
'foreignKey' => 'status_id',
'conditions' => array('AgencyStatus.option_list_id'=>20)
),
'BednightNotUsedReason' => array(
'className' => 'Bednight',
'foreignKey' => 'not_used_reason_id',
'conditions' => array('BednightNotUsedReason.option_list_id'=>26)
),
'ClientLA' => array(
'className' => 'Client',
'foreignKey' => 'la_id',
'conditions' => array('ClientLA.option_list_id'=>32)
),
'HouseholdStatus' => array(
'className' => 'Household',
'foreignKey' => 'status_id',
'conditions' => array('HouseholdStatus.option_list_id'=>25)
),
'PersonEthnicity' => array(
'className' => 'Person',
'foreignKey' => 'ethnicity_id',
'conditions' => array('PersonEthnicity.option_list_id'=>13)
),
'PersonGender' => array(
'className' => 'Person',
'foreignKey' => 'gender_id',
'conditions' => array('PersonGender.option_list_id'=>12)
),
'PersonReligion' => array(
'className' => 'Person',
'foreignKey' => 'religion_id',
'conditions' => array('PersonReligion.option_list_id'=>30)
),
'PersonSexuality' => array(
'className' => 'Person',
'foreignKey' => 'sexuality_id',
'conditions' => array('PersonSexuality.option_list_id'=>18)
),
'ReferralReasonClientDeclined' => array(
'className' => 'Referral',
'foreignKey' => 'declined_reason_id',
'conditions' => array(
'ReferralReasonClientDeclined.offer_status'=>2,
'ReferralReasonClientDeclined.option_list_id'=>22
)
),
'ReferralReasonSchemeDeclined' => array(
'className' => 'Referral',
'foreignKey' => 'declined_reason_id',
'conditions' => array(
'ReferralReasonSchemeDeclined.offer_status'=>1,
'ReferralReasonSchemeDeclined.option_list_id'=>21
)
),
'SchemeRegion' => array(
'className' => 'Scheme',
'foreignKey' => 'region_id',
'conditions' => array('SchemeRegion.option_list_id'=>5)
),
'SchemeStatus' => array(
'className' => 'Scheme',
'foreignKey' => 'status_id',
'conditions' => array
('AgenSchemeStatusyStatus.option_list_id'=>10)
),
'StaffStatus' => array(
'className' => 'Staff',
'foreignKey' => 'status_id',
'conditions' => array('StaffStatus.option_list_id'=>15)
)
);
--~--~---------~--~----~------------~-------~--~----~
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