When baking a model with CakePHP, why does it prompt for hasOne if it asked hasMany and received an answer of yes already? Is it there a situation when both are appropriate? I would expect some of the behaviors to conflict...
views:
32answers:
1
+1
A:
You may hypothetically have a "primary" hasMany related model which you want quick access to, something like:
var $hasMany = array('Address');
var $hasOne = array(
'PrimaryAddress' => array(
'className' => 'Address',
'conditions' => array('PrimaryAddress.type' => 'primary')
)
);
The reason why bake
asks you twice is probably primarily because nobody bothered to implement a check of whether you already selected a hasMany
or not, or because they consciously decided to leave the door open for the above case.
deceze
2010-06-04 02:03:33
Makes sense - thanks!
BWelfel
2010-06-04 02:40:13