1

我在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 的有效父关系。您的关系配置正确吗?

谢谢你!

4

0 回答 0