0

我正在尝试从 yaml 模式生成学说模型

我有这样的架构:

Product:
    columns:
        id:
            type: integer(5)
            primary: true
            unsigned: true
            autoincrement: true
        activation_time:
            type: datetime
            notnull: true
        enduser_id:
            type: integer(5)
            unsigned: true
            notnull: true
    relations:
        Enduser:
            foreignType: one
            type: one
            foreignAlias: Product

Hostid:
    columns:
        id:
            type: integer(5)
            primary: true
            unsigned: true
            autoincrement: true
        value:
            type: string(32)
            fixed: true
            notnull: true

Order:
    columns:
        id:
            type: integer(5)
            primary: true
            autoincrement: true
            unsigned: true
        expire_date:
            type: datetime
        description:
            type: clob

Enduser:
    columns:
        id:
            type: integer(5)
            primary: true
            unsigned: true
            autoincrement: true
        hostid_id:
            type: integer(5)
            unsigned: true
            notnull: true
        order_id:
            type: integer(5)
            unsigned: true
            notnull: true
    relations:
        Order:
            foreignAlias: Endusers
        Hostid:
            foreignAlias: Endusers

问题是由学说 generate-models-yaml 生成的模型在 BaseEnduser 中是错误的 $Product 被定义为 Doctrine_Collection

$this->hasMany('Product', array('local' => 'id', 'foreign' => 'enduser_id'));

而只是 Product 对象

我做错了什么?

关系被定义为foreignType:一种类型:一种

4

1 回答 1

0

根据一对一的例子,你只需为“产品”做

relations:
    Enduser:
        foreignType: one

其余的似乎很好海事组织。无需定义其他内容,因为您仅将最终用户的引用与它的产品一起存储(以某种方式连接而不知道您想要做什么,用户不能拥有很多产品,反之亦然?)

于 2010-12-30T17:50:59.753 回答