未知的记录属性/相关组件,多个引用到一个表

时间:2012-06-08 09:10:25

标签: symfony1 reference doctrine

模型定义中的

    $this->hasMany('Photo', array(
         'refClass' => 'StyleLangHasPhoto',
         'local' => 'style_lang_id',
         'foreign' => 'photo_id'));

    $this->hasMany('Photo as Preview', array(
         'refClass' => 'StyleLangHasPreviewPhoto',
         'local' => 'style_lang_id',
         'foreign' => 'photo_id'));

但是getter getPreview甚至$this->_get('Preview')会引发Unknown record property / related component "Preview" on "StyleLang"

我试着这样做

    $this->hasMany('Photo as Slide', array(
         'refClass' => 'StyleLangHasPhoto',
         'local' => 'style_lang_id',
         'foreign' => 'photo_id'));

    $this->hasMany('Photo as Preview', array(
         'refClass' => 'StyleLangHasPreviewPhoto',
         'local' => 'style_lang_id',
         'foreign' => 'photo_id'));

但没有任何改变

我做错了什么?

UDP1: getPhoto,setPhoto,setPreview效果不错

1 个答案:

答案 0 :(得分:0)

问题解决了

foreignAlias: relationsPhoto中{p> Preview必须不同

感谢名单