Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Doctrine2] Relacja OneToMany
pitu
post
Post #1





Grupa: Zarejestrowani
Postów: 476
Pomógł: 96
Dołączył: 10.04.2008
Skąd: Koszalin

Ostrzeżenie: (0%)
-----


Hej!

Mam dziwny problem i nie mogę znaleźć przyczyny.

Posiadam dwa modele:
- user
- comment

W encjach (podam tylko to co dotyczy relacji)

User:
  1. use Doctrine\Common\Collections\ArrayCollection;
  2.  
  3. /**
  4.   * @OneToMany(targetEntity="Comment", mappedBy="user")
  5.   */
  6. protected $comments;
  7.  
  8. public function __construct() {
  9. $this->comments= new ArrayCollection();
  10. }


Comment:
  1. /**
  2.   * @ManyToOne(targetEntity="User", inversedBy="comments")
  3.   * @JoinColumn(name="user_id", referencedColumnName="id")
  4.   **/
  5. 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.


--------------------
HTML/CSS/JS: jsfiddle
SQL: sqlfiddle
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 12:25