我在codeigniter中遇到datamapper orm的问题......:O
我的第一个模特:
class Mil_widget extends DataMapper {
// Insert related models that Mil_widget can have more than one of.
var $has_many = array(
'mil_relationship' => array(
'join_table' => 'mil_fields_mil_widgets'
)
);
}
这是我的另一个模特:
class Mil_relationship extends DataMapper {
// Insert related models that Mil_widget can have more than one of.
var $has_many = array(
'mil_widget' => array(
'join_table' => 'mil_fields_mil_widgets'
)
);
}
如果我这样做它可以工作并保存正确的数据库条目:
$w = new Mil_widget(1);
$r = new Mil_relationship(1);
$w->save($r);
但如果我这样做,我会收到错误:
$w->mil_relationship->get();
这就是错误:
DataMapper错误:'mil_widget'不是有效的父关系 Mil_relationship。您的关系配置正确吗?
谢谢!