[英]Doctrine 2 association mapping errors
我有2个实体:
Brs\UserBundle\Entity\User:
type: entity
table: user
repositoryClass: Brs\UserBundle\Entity\UserRepository
id:
id:
type: integer
generator: { strategy: AUTO }
fields:
username:
type: string
length: 50
fname:
type: string
length: 30
lname:
type: string
length: 30
email:
type: string
length: 75
mobile:
type: string
length: 20
active:
type: boolean
mentor:
type: boolean
roll:
type: string
length: 10
profitPercentage:
type: string
length: 10
initialized:
type: datetime
password:
type: string
length: 255
oneToMany:
requests:
targetEntity: Brs\FundingBundle\Entity\Request
mappedBy: requests
和:
Brs\FundingBundle\Entity\Request:
type: entity
table: null
repositoryClass: Brs\FundingBundle\Entity\RequestRepository
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
amount:
type: integer
status:
type: integer
datetime:
type: datetime
note:
type: string
length: 255
approval:
type: boolean
manyToOne:
user:
targetEntity: Brs\UserBundle\Entity\User
inversedBy: user
lifecycleCallbacks: { }
在Brs \\ FundingBundle \\ Entity \\ Request中:
我声明了该属性:
private $user;
并在Brs \\ FundingBundle \\ Entity \\ User中:
我声明了该属性:
private $requests;
当我跑步时:
php app/console doctrine:schema:update --force
我得到以下结果:
Updating database schema...
Database schema updated successfully! "3" queries were executed
看起来不错,这将创建请求表并向其中添加user_id外键,这正是我想要的。
但是,我已经在Doctrine 2关联映射中仔细研究了文档,而且似乎无法自信地理解逆逻辑,拥有逻辑和mappedBy逻辑。
如果有人可以针对我上面的示例对此进行详尽的解释,将不胜感激。
因此,在这种情况下,用户有很多请求。
提前致谢。
阅读此 。
可能使用注释会更方便。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.