Reputation: 683
I just want to know what are advantages/drawback of a bidirectional relation in Doctrine with Symfony ?
All my relations are bidirectional, but I'm not sure if this will not cause a problem...
Thanks.
Upvotes: 4
Views: 233
Reputation: 20193
As long as you don't mark relations as EAGER
I think you're good. to go.
However, there is a small overhead since PHP
has to, at least, create Proxy
instances. Beware of this if you plan on serializing objects. Some serialization mechanism are programmed to resolve (load) proxy if they hit one. That would mean an extra round-trip to database server.
Bottom line: As you develop your model, ask yourself "Do I really need this?". It's super easy to add it later if you find yourself in that situation. Also, when it comes to OneToMany
and ManyToOne
, pay special attention to owning
/inverse
side concepts as it could introduce a number of WTFs/minute :)
Hope this helps you a bit...
Upvotes: 2