我正在使用kohana 3.2,我需要帮助has_many关系。该表写成空数据...
因此,我的User_education
模型看起来像:http://gyazo.com/218139e52d85718c0d47bb802f0856fe User_personal
模型:http://gyazo.com/49fd4ab4fb7506cf8b7c608733a70365
和控制器:http://gyazo.com/7d13dd3901870d7ad3d62c09e90a9c14但数据库中的字段仍为空
答案 0 :(得分:0)
您应该在模型中指定外键:
class Model_User_Personal extends ORM
{
protected $_has_many = array(
'educations' => array(
'model' => 'user_education',
'foreign_key' => 'user_personal_id',
),
);
}
应在Model_User_Education
:
class Model_User_Education extends ORM
{
protected $_belongs_to = array(
'user_personal' => array(
'model' => 'user_personal',
'foreign_key' => 'user_personal_id',
),
);
}