Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Doctrine 2 “Found entity of type on association but expected”, Doctrine Symfony2
gentleman
post
Post #1





Grupa: Zarejestrowani
Postów: 41
Pomógł: 1
Dołączył: 17.05.2013

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


Mam problem problem z przesłaniem danych.

entity User.php
  1. /**
  2.   * @var \Doctrine\Common\Collections\ArrayCollection
  3.   *
  4.   * @ORM\ManyToMany(targetEntity="Acme\CommentBundle\Entity\Following")
  5.   * @ORM\JoinTable(name="following",
  6.   * joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
  7.   * inverseJoinColumns={@ORM\JoinColumn(name="follower_id", referencedColumnName="id")}
  8.   * )
  9.   */
  10. protected $followers;


Following.php
  1. protected $id;
  2.  
  3. protected $user_id;
  4.  
  5. protected $follower_id;


Gdy próbuje tak:
  1. $em = $this->getDoctrine()->getManager();
  2. $follower = $em->getRepository('AcmeUserBundle:User')->findOneBy(array('id' = 1));
  3. $user = $this->get('security.context')->getToken()->getUser();
  4. $user->getFollowers()->add($follower);
  5. $em->flush();


otrzymuje błąd Found entity of type Acme\UserBundle\Entity\User on association Acme\UserBundle\Entity\User#followers, but expecting Acme\CommentBundle\Entity\Following

Dlaczego?

#prolem rozwazany

Ten post edytował gentleman 17.07.2014, 18:00:04
Go to the top of the page
+Quote Post

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 - 17:40