0

I am trying generate doctrine models from yaml schema

I have schema like that:

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

and the problem is that models generated by doctrine generate-models-yaml are wrong in BaseEnduser $Product is defined as Doctrine_Collection

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

instead just Product object

what did I wrong?

relation is defined as foreignType: one type: one

mrok
  • 2,680
  • 3
  • 27
  • 46

1 Answers1

0

Accodring to the one-to-one example, you just do for "Product"

relations:
    Enduser:
        foreignType: one

The rest seems fine IMO. No need to define something else since you only store the reference of the Enduser with it's product (which is wired somehow without knowing what you want to do, can't a user have many products and vice-versa?)

DrColossos
  • 12,656
  • 3
  • 46
  • 67
  • Thats the problem, I did as you wrote (foreignType: one) and it is not working ;( – mrok Dec 31 '10 at 11:19
  • Do you have the possbility to create the database and let Doctrine generate the models/yml for you? Sounds stupid but this way, you can see where the error lies. – DrColossos Dec 31 '10 at 18:38
  • I solved it. Instead of tab I use 2 spaces and everything went well. – mrok Jan 22 '11 at 09:54