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

そして問題は、doctrine generate-models-yaml によって生成されたモデルが BaseEnduser で間違っていることです $Product は Doctrine_Collection として定義されています

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

代わりに、製品オブジェクトのみ

私は何を間違えましたか?

関係は、foreignType: one type: one として定義されます

4

1 に答える 1

0

1対1の例によると、「製品」に対して行うだけです

relations:
    Enduser:
        foreignType: one

残りは問題ないようです。エンドユーザーの参照をその製品と一緒に保存するだけなので、他に何かを定義する必要はありません (これは、何をしたいのかを知らずに何らかの方法で配線されています。ユーザーは多くの製品を持つことができず、その逆もありませんか?)

于 2010-12-30T17:50:59.753 に答える