What values goes inside this inversedBy annotation as well as the mappedBy annotation? Also what is targetEntity and referencedColumnName?
Here is an example of my comment entity. As you can see, in my tutorials it says to write the string comments inside the inversedBy attribute and \Application\Entity\Post inside the targetREntity attribute.
/**
* This class represents a comment related to a blog post.
* @ORM\Entity
* @ORM\Table(name="comment")
*/
class Comment
{
/**
* @ORM\ManyToOne(targetEntity="\Application\Entity\Post", inversedBy="comments")
* @ORM\JoinColumn(name="post_id", referencedColumnName="id")
*/
protected $post;
}
For this one, it says comments. What exactly is this comments string referring to?
I dont know what comments means. Is this a mapping to a table, or the ORM name of the class at the top, or something else.
Also,
Here is an example of where mappedBy is used:
/**
* @ORM\Entity
* @ORM\Table(name="post")
*/
class Post
{
// Post status constants.
const STATUS_DRAFT = 1; // Draft.
const STATUS_PUBLISHED = 2; // Published.
/**
* @ORM\OneToMany(targetEntity="\Application\Entity\Comment", mappedBy="post")
* @ORM\JoinColumn(name="id", referencedColumnName="post_id")
*/
protected $comments;
I started reading about owning sides and inverse sides click here but it was extremely difficult to understand.
Any details on anything here would be great.
Any help would be great.