Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Symfony 2 - Problem z Doctrine
M4ver7071
post
Post #1





Grupa: Zarejestrowani
Postów: 63
Pomógł: 0
Dołączył: 26.06.2014

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


Witam, chcę zrobić pole do szukania przedmiotu w Symfony 2. Napisałem kod który powinien działać poprawnie, ale zwraca mi pustą tablicę. Próbowałem już kilka sposób, taki produkt jest w bazie a nie wiem dlaczego zwraca pustą tablicę.


  1.  
  2. public function showAction(Request $request)
  3. {
  4. //$word = $request->query->get('keywords')['search'];
  5. $word = 'toshiba';
  6.  
  7. $repository = $this->getDoctrine()->getRepository('CustomExampleBundle:Product');
  8.  
  9. $query = $repository->createQueryBuilder('p')
  10. ->where('p.title= :word')
  11. ->setParameter('word', '%'.$word.'%')
  12. ->getQuery();
  13. $result = $query->getArrayResult();
  14.  
  15. print_r($result); die;
  16. // return $this->render('CustomExampleBundle:Search:search.html.twig', array(
  17. // 'entity' => $result));
  18. }

Proszę o pomoc.

Ten post edytował M4ver7071 19.02.2015, 20:18:17
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 26.12.2025 - 11:00