Jump to content

Recommended Posts

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;

    }

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.