我想獲得一個在Symfony 3.2.6/PHP 7.1上工作的manyToMay雙向映射。我無法獲得學說manyToMany定義不工作未定義索引:joinTable
php bin/console doctrine:schema:update --dump-sql
命令沒有錯誤
[Symfony的\分量\調試\異常\ ContextErrorException] 注意運行:未定義指數:joinTable
定義如下:
Busybee\StudentBundle\Entity\Student:
type: entity
table: student
repositoryClass: Busybee\StudentBundle\Repository\StudentRepository
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
startAtSchool:
type: date
manyToMany:
enrolments:
targetEntity: Busybee\StudentBundle\Entity\Enrolment
mappedBy: students
和
Busybee\StudentBundle\Entity\Enrolment:
type: entity
table: enrolment
repositoryClass: Busybee\StudentBundle\Repository\EnrolmentRepository
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
status:
type: string
length: '32'
lastModified:
type: datetime
createdOn:
type: datetime
manyToMany:
students:
targetEntity: Busybee\StudentBundle\Entity\Student
inversedBy: enrolments
如果我刪除了Student Entity中的mappedBy,則SQL將使用doctrine:schema:update命令生成。在http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/association-mapping.html#owning-and-inverse-side-on-a-manytomany-association的例子顯示了inversedBy實體此或實體的mappedBy仍生成錯誤未定義指數joinTable指數,並添加joinTable:joinTable
所以,如果有什麼我做錯了什麼?這是一個錯誤?任何幫助非常感謝。
Craig
你刪除/重新創建你的數據庫?如果你有一個現有的數據庫,然後添加/修改這些實體的結構,你可能在修改中遇到了一個錯誤。這通常可以通過重新開始來解決。顯然你不想在生產網站上做到這一點! – ehymel
感謝您的評論。是的,刪除了所有表格,失敗仍然存在。 –