Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [SF][SF2][Symfony2]Nie pobiera danych z bazy danych
Crash89
post 27.11.2016, 11:39:50
Post #1





Grupa: Zarejestrowani
Postów: 191
Pomógł: 7
Dołączył: 3.04.2013

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


Mam taki problem, otóż wszystko działa prawie prawidłowo. Chcę pobrać z bazy informację czy użytkownik juz zagłosował na dany product i na jeden produkt są zwracane dane ale na inne nie.
Mimo tego że gdy w phpmyadmin ręcznie wpisując dane wszystko się zgadza.

To jest kod który to obsługuje:

  1. public function checkIfUserVote($user, $product)
  2. {
  3. if($user === 'anon.')
  4. {
  5. return true;
  6. }
  7.  
  8. $rate = $this->em->getRepository('AppBundle:Rate')->getRateProductUser($user->getId(),$product->getId());
  9.  
  10.  
  11.  
  12. if(!empty($rate))
  13. {
  14. return false;
  15. }else{
  16. return true;
  17. }
  18. }


i w repozytorium:

  1.  
  2. public function getRateProductUser($productId, $userId)
  3. {
  4. return $this->createQueryBuilder('r')
  5. ->where('r.product = :product AND r.user = :user')
  6. ->setParameter('product',$productId)
  7. ->setParameter('user',$userId)
  8. ->getQuery()
  9. ->getResult();
  10. }


Ten post edytował Crash89 27.11.2016, 11:40:41
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 Wersja Lo-Fi Aktualny czas: 25.06.2025 - 15:19