[英]Kohana has_many relationship
I'm using kohana 3.2 and I need help with has_many relationship. 我正在使用kohana 3.2,并且需要has_many关系方面的帮助。 The table is written empty data...
该表被写入空数据...
So, my User_education
model look like: http://gyazo.com/218139e52d85718c0d47bb802f0856fe User_personal
model : http://gyazo.com/49fd4ab4fb7506cf8b7c608733a70365 因此,我的
User_education
模型如下所示: http : User_personal
模型: http : User_personal
and controller: http://gyazo.com/7d13dd3901870d7ad3d62c09e90a9c14 but fields in database still empty 和控制器: http : //gyazo.com/7d13dd3901870d7ad3d62c09e90a9c14,但数据库中的字段仍然为空
You should specify the foreign key in your models: 您应该在模型中指定外键:
class Model_User_Personal extends ORM
{
protected $_has_many = array(
'educations' => array(
'model' => 'user_education',
'foreign_key' => 'user_personal_id',
),
);
}
The same foreign key should be set in Model_User_Education
: 应在
Model_User_Education
设置相同的外键:
class Model_User_Education extends ORM
{
protected $_belongs_to = array(
'user_personal' => array(
'model' => 'user_personal',
'foreign_key' => 'user_personal_id',
),
);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.