【发布时间】:2015-12-01 01:14:38
【问题描述】:
我不明白与 Doctrine2 的关系。我正在尝试遵循文档,但它缺乏正确的解释。
我有 Client、Material、Budget 和 Orders 表。 Budget 表单列出了前两个表中的数据,我需要将它们与 Order 相关联,这将存储客户的 id 和他需要的所有材料的 id。因此,按照文档,我在Orders.orm.yml 中达到了这个结果:
CDG\PanelBundle\Entity\Orders:
type: entity
table: orders
repositoryClass: CDG\PanelBundle\Entity\OrdersRepository
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
materialQuantity:
type: integer
column: material_quantity
materialPrice:
type: decimal
column: material_price
dateCreated:
type: datetime
column: date_created
oneToOne:
clientId:
targetEntity: Client
joinColumn:
name: client_id
referencedToColumnName: id
order:
targetEntity: Orders
joinColumn:
name: order
referencedToColumnName: id
manyToOne:
materialId:
targetEntity: Material
joinColumn:
name: material_id
mappedBy: materials
lifecycleCallbacks: { }
我的Material.orm.yml:
CDG\PanelBundle\Entity\Material:
type: entity
table: material
repositoryClass: CDG\PanelBundle\Entity\MaterialRepository
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
name:
type: string
column: name
length: 255
description:
type: string
column: description
length: 255
quantity:
type: integer
column: quantity
price:
type: integer
column: price
oneToMany:
materials:
targetEntity:
lifecycleCallbacks: { }
还有Budget.orm.yml
CDG\PanelBundle\Entity\Budget:
type: entity
table: null
repositoryClass: CDG\PanelBundle\Entity\BudgetRepository
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
clientName:
type: string
length: 255
column: client_name
materials:
type: array
address:
type: string
length: 255
installments:
type: integer
checkDays:
type: integer
column: check_days
totalValue:
type: decimal
column: total_value
order:
type: integer
lifecycleCallbacks: { }
在我的主页中,我列出了所有 3 个表中的最后五个数据,我收到此错误:
注意:未定义索引:mappedBy
【问题讨论】: