Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Symfony][Symfony2] niepoprawne zapytanie w query_builder
dragon7
post
Post #1





Grupa: Zarejestrowani
Postów: 51
Pomógł: 0
Dołączył: 1.10.2010

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


Witam. Mój formularz podczas tworzenia generuje złe zapytanie SQL.
($this->sphere jest instancją Mns\PytaniaBundle\Entity\Sphere)

  1. $builder->add('category', 'entity', array(
  2. 'class' => 'MnsPytaniaBundle:Category',
  3. 'label' => 'w ',
  4. 'query_builder' => function(EntityRepository $er)
  5. {
  6. return $er->createQueryBuilder('c')->select('c')->where('c.sphere', $this->sphere);
  7. }));


Otrzymuje błąd:
CODE
Expression of type 'Mns\PytaniaBundle\Entity\Sphere' not allowed in this context.


A zapytanie, które powstało to:
  1. SELECT t0.id AS id1, t0.name AS name2, t0.rank AS rank3, t0.question_number AS question_number4 FROM sphere t0 WHERE t0.id = ? (["2"])


Dlaczego chce pobrać z Sphere zamiast Category?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
pamil
post
Post #2





Grupa: Zarejestrowani
Postów: 97
Pomógł: 15
Dołączył: 12.08.2012
Skąd: Zabrze

Ostrzeżenie: (10%)
X----


Zapoznaj się z dokumentacją metody where() w QueryBuilder. Złe argumenty podałeś.
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: 19.08.2025 - 03:31