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 开发者_Go百科there a situation when both are appropriate? I would expect some of the behaviors to conflict...
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.
精彩评论