I have 2 Tables
And the Structure of Tables:
Users:
Messages:
Now see there are number of users in Users Table and their messages are stored in Messages table identifying by sender_id and receiver_id
How can I make One-To-Many and Many To One Relationship between these two tables or create this SQL Schema using Doctrine/Annotations?
Something like that:
/**
* @ORM\Entity
* @ORM\Table(name="messages")
*/
class Comment
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length=5000, nullable=true)
*/
protected $text;
/**
* Author of the comment
*
* @ORM\ManyToOne(targetEntity="Acme\UserBundle\Entity\User")
* @var User
*/
protected $sender;
/**
*
*
* @ORM\ManyToOne(targetEntity="Acme\UserBundle\Entity\User")
* @var User
*/
protected $reciever;