我不理解与Doctrine2的关系。我正在尝试按照文档,但它缺乏适当的解释。注意:未定义索引:mappedBy
我客户,材料,预算和订单表。 预算形式列出了前两个表中的数据,我需要将它们都与订购相关联,这将存储客户端的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个表格的最后五个数据,并且我得到这个错误:
Notice: Undefined index: mappedBy
虽然这是真的,但错误并非由于特定的“不匹配”而导致的,所以这根本就不是一个有效的答案 – DonCallisto