blacktie524 Posted March 1, 2011 Share Posted March 1, 2011 I am just starting out with Doctrine 2 and trying to test out a bidirectional One to Many relationship. In this case, I have a user, which can have many comments. I have checked the Doctrine 2 documentation and it seems that I am doing it right, but it takes a really looong time to execute my script (with just a few rows in each tables), and I'm hoping someone can help point me in the right direction. Here is the php: /** * @Entity * @Table(name="users") */ class User { /** * @Id @GeneratedValue * @Column(type="bigint") * @var integer */ private $id; /** * @Column(type="string", length="250") * @var string */ protected $name; /** * @OneToMany(targetEntity="Comment", mappedBy="user") */ private $comments; } /** * @Entity * @Table(name="comments") */ class Comment { /** * @Id @GeneratedValue * @Column(type="bigint") * @var integer */ private $id; /** * @Column(type="text") * @var string */ private $text; /** * @ManyToOne(targetEntity="User", inversedBy="comments") * @JoinColumn(name="user_id", "referencedColumnName="id") */ private $user; } Link to comment https://forums.phpfreaks.com/topic/229316-doctrine-2-bidirectional-one-to-many-relationship-loading-extremely-slow/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.