Symfony2: Call to undefined method Doctrine\ORM\QueryBuilder::getResult()

LanMan

With the code:

$qb = $entityManager->createQueryBuilder();
$qb->select('cat')->from('BuyAndSellSiteBundle:Category ', 'cat');
$qb->getQuery();
$a =$qb->getResult();

I get an exception:

FatalErrorException: Error: Call to undefined method Doctrine\ORM\QueryBuilder::getResult() in C:\xampp\htdocs\buySell\src\BuyAndSell\SiteBundle\Controller\DefaultController.php line
Jovan Perovic

This makes sense. Because QueryBuilder does not change itself, you need to store result of getQuery() invocation :

$queryBuilder = $entityManager->createQueryBuilder();
$queryBuilder->select('cat')->from('BuyAndSellSiteBundle:Category ', 'cat');

// get the Query from the QueryBuilder here ...
$query = $qb->getQuery();

// ... then call getResult() on the Query (not on the QueryBuilder)
$result = $query->getResult(); 

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Symfony2: Call to undefined method Doctrine\ORM\QueryBuilder::getResult()

From Dev

Symfony 3 - undefined method named "getResult"

From Dev

Symfony2 - Fatal error: Call to undefined method Symfony\Bundle\DoctrineBundle\Registry::getManager()

From Dev

Symfony2: Undefined method: getDoctrine()

From Dev

Symfony2 and Doctrine entity undefined method

From Dev

Symfony2 and Doctrine entity undefined method

From Dev

Symfony2 Sylius CartBundle setVariant method undefined

From Dev

Can not call method of undefined

From Dev

Call to undefined method error

From Dev

Attempted to call an undefined method named "getpreReady" (Twig & Symfony3)

From Dev

Symfony create new object many to one error call undefined method

From Dev

symfony 2 - Attempted to call an undefined method named "findBy" of class "testBundle\Entity\test"

From Dev

Call to undefined method Slice in Doctrine

From Dev

Error: Call to a possibly undefined method

From Dev

Laravel 5 - Call to undefined method

From Dev

Laravel - Call to undefined method in repository

From Dev

Call to undefined method DOMDocument::getElementsByClassName()

From Dev

Rails 4.0 undefined method `call'

From Dev

TypeError: Cannot call method 'then' of undefined

From Dev

Call to undefined method PDO::execute()

From Dev

Cannot call method 'use' of undefined

From Dev

Call to undefined method (laravel 5.2)

From Dev

Call to undefined method Closure::query()

From Dev

Call to undefined method Imagick::writeImageFile()

From Dev

BackboneJS - Cannot call method 'on' of undefined

From Dev

Call to undefined method SimpleXMLElement::getAttribute()

From Dev

Javascript: Cannot call method of undefined

From Dev

Call to undefined method MongoDB::find()

From Dev

Cannot call method 'use' of undefined

Related Related

  1. 1

    Symfony2: Call to undefined method Doctrine\ORM\QueryBuilder::getResult()

  2. 2

    Symfony 3 - undefined method named "getResult"

  3. 3

    Symfony2 - Fatal error: Call to undefined method Symfony\Bundle\DoctrineBundle\Registry::getManager()

  4. 4

    Symfony2: Undefined method: getDoctrine()

  5. 5

    Symfony2 and Doctrine entity undefined method

  6. 6

    Symfony2 and Doctrine entity undefined method

  7. 7

    Symfony2 Sylius CartBundle setVariant method undefined

  8. 8

    Can not call method of undefined

  9. 9

    Call to undefined method error

  10. 10

    Attempted to call an undefined method named "getpreReady" (Twig & Symfony3)

  11. 11

    Symfony create new object many to one error call undefined method

  12. 12

    symfony 2 - Attempted to call an undefined method named "findBy" of class "testBundle\Entity\test"

  13. 13

    Call to undefined method Slice in Doctrine

  14. 14

    Error: Call to a possibly undefined method

  15. 15

    Laravel 5 - Call to undefined method

  16. 16

    Laravel - Call to undefined method in repository

  17. 17

    Call to undefined method DOMDocument::getElementsByClassName()

  18. 18

    Rails 4.0 undefined method `call'

  19. 19

    TypeError: Cannot call method 'then' of undefined

  20. 20

    Call to undefined method PDO::execute()

  21. 21

    Cannot call method 'use' of undefined

  22. 22

    Call to undefined method (laravel 5.2)

  23. 23

    Call to undefined method Closure::query()

  24. 24

    Call to undefined method Imagick::writeImageFile()

  25. 25

    BackboneJS - Cannot call method 'on' of undefined

  26. 26

    Call to undefined method SimpleXMLElement::getAttribute()

  27. 27

    Javascript: Cannot call method of undefined

  28. 28

    Call to undefined method MongoDB::find()

  29. 29

    Cannot call method 'use' of undefined

HotTag

Archive