我正在尝试从yaml schema
生成教义模型我有这样的架构:
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:一个 类型:一个
答案 0 :(得分:0)
根据one-to-one example,您只需为“产品”
relations:
Enduser:
foreignType: one
其余的看起来很好IMO。无需定义其他内容,因为您只存储Enduser的引用及其产品(以某种方式连接而不知道您想要做什么,用户不能拥有多个产品,反之亦然?)