Mam dziwny problem i nie mogę znaleźć przyczyny.
Posiadam dwa modele:
- user
- comment
W encjach (podam tylko to co dotyczy relacji)
User:
use Doctrine\Common\Collections\ArrayCollection; /** * @OneToMany(targetEntity="Comment", mappedBy="user") */ protected $comments; public function __construct() { $this->comments= new ArrayCollection(); }
Comment:
/** * @ManyToOne(targetEntity="User", inversedBy="comments") * @JoinColumn(name="user_id", referencedColumnName="id") **/ protected $user;
Próbując wyciągnąć komentarze $user->getComments(); zwraca mi zamiast tablicy komentarzy lub null obiekt użytkownika.
Chyba za długo siedzę dzisiaj przed monitorem i nie widzę błędu.