Reputation: 147
I am making blog maker in symfony and doctrine
I am trying to connect, ID of row in blog posts with comments by blog_id value, but I getting this error
\Entity\BlogPosts.php
The association App\Entity\BlogPosts#comments refers to the owning side field App\Entity\Frontend\Blog\Fe_blog_comments#blogId which is not defined as association, but as field.
The association App\Entity\BlogPosts#comments refers to the owning side field App\Entity\Frontend\Blog\Fe_blog_comments#blogId which does not exist.
My actual code looks like this
\Entity\BlogPosts.php
class BlogPosts
{
/**
* @ORM\OneToMany(targetEntity="App\Entity\Frontend\Blog\Fe_blog_comments", mappedBy="blogId")
*/
private $comments;
//...
}
\Entity\Frontend\Blog\Fe_blog_comments.php
class Fe_blog_comments
{
//...
/**
* @ORM\Column(type="integer")
* @ORM\ManyToOne(targetEntity="App\Entity\BlogPosts", inversedBy="comments")
* @ORM\JoinColumn(name="blog_id", referencedColumnName="id")
*/
private $blogId;
//...
}
Upvotes: 0
Views: 75
Reputation: 309
Remove @ORM\Column(type="integer")
, the column should be managed by @ORM\JoinColumn(name="blog_id", referencedColumnName="id")
Upvotes: 1