请告诉我创作的关系就像蛋糕PHP中使用表关系
var $belongsTo = array(
'UserType' => array(
'className' => 'UserType',
'foreignKey' => 'user_type_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
//The Associations below have been created with all possible keys, those that are not needed can be removed
var $hasMany = array(
'UserOpenid' => array(
'className' => 'UserOpenid',
'foreignKey' => 'user_id',
'dependent' => true)
);
如果我加入这“属于关联”的感觉产生,在“的hasMany”表中的使用情况如何? 发生任何错误。 蛋糕如何使用模型中指定的关系?
你可以把你的代码示例在代码标签中吗?它会使阅读更容易。 – 2010-02-06 14:59:24
好的,如果我指定喜欢这篇文章hasMany用户我无法获取用户名rite? – udhaya 2010-02-06 13:00:37
我认为你说的是用户有很多帖子。那么在这种情况下,当你选择一个特定的用户时,你也会得到他所有的评论。 阅读有关模型协会的食谱http://book.cakephp.org/view/78/Associations-Linking-Models-Together – PawelMysior 2010-02-06 14:50:24