Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3925

Symfony 4 self-referencing association for recommended article

$
0
0

I have entity article with column title and text. Now I want to add up 3 recommended another articles to each. In documentation I read about doctrine selfrefrencing associtin and I dont know If I use onetomany or manytomany. I have this code

/**     * @ManyToMany(targetEntity="Article", mappedBy="myRecommendation")     */    private $recommended;    /**     * @ManyToMany(targetEntity="Article", inversedBy="recommended")     * @JoinTable(name="recommended",     *      joinColumns={@JoinColumn(name="article_id", referencedColumnName="id")},     *      inverseJoinColumns={@JoinColumn(name="recommend_article_id", referencedColumnName="id")}     *      )     */    private $myRecommendation;

is this association right? And which is owning side? Which is method for adding recommende article?


Viewing all articles
Browse latest Browse all 3925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>