Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Symfony][Symfony2][Doctrine2]Natywny sql problem z zapytaniem zwraca null
silverwind
post
Post #1





Grupa: Zarejestrowani
Postów: 80
Pomógł: 0
Dołączył: 8.02.2013

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


Dlaczego mi zwraca null przy natywny sql w zapytaniu. Dump w szablonie są same null.

  1. public function getExpensesByProperty()
  2. {
  3.  
  4. $rsm = new ResultSetMapping;
  5.  
  6. $rsm->addEntityResult('User\UserBundle\Entity\User', 'u');
  7.  
  8. $rsm->addFieldResult('u', 'username', 'username');
  9.  
  10. $sql = "
  11. SELECT username
  12. FROM users
  13.  
  14. ";
  15.  
  16.  
  17.  
  18.  
  19. $query= $this->_em->createNativeQuery(
  20. $sql, $rsm
  21. );
  22.  
  23.  
  24.  
  25. return $query->getResult();
  26.  
  27. }
  28. }
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
silverwind
post
Post #2





Grupa: Zarejestrowani
Postów: 80
Pomógł: 0
Dołączył: 8.02.2013

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


Potrzebuję takie zapytania zrobić ale widzę że nie jest to takie łatwe
  1. SELECT `users`.`username`,`owner`.`name`,`property`.`name` AS `p`,`property`.`adress`,`expenses`.`name` , SUM(`expenses`.`price`) AS `s`,`property`.`id` AS `i` FROM `users` INNER JOIN `owner` ON `users`.`id`=`owner`.`user_id`
  2. INNER JOIN `property`ON `owner`.`id`=`property`.`owner_id`
  3. LEFT JOIN `expenses`ON `property`.`id`=`expenses`.`property_id`
  4. GROUP BY `property`.`id`,`expenses`.`id`
  5. UNION SELECT `users`.`username`,`owner`.`name`,`property`.`name`,`property`.`adress`,`expenses`.`name`=NULL,SUM(`expenses`.`price`),`property`.`id` FROM `users`
  6. INNER JOIN `owner`ON `users`.`id`=`owner`.`user_id`
  7. INNER JOIN `property`ON `owner`.`id`=`property`.`owner_id`
  8. LEFT JOIN `expenses`ON `property`.`id`=`expenses`.`property_id`
  9. GROUP BY `property`.`id`
  10. ORDER BY `i`,`s`
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: 13.10.2025 - 19:36