pdchaudhary
pdchaudhary

Reputation: 388

how to use Querybuilder in symfony 3.4 with mongodb doctrine?i have issue i try but this is not give data. this is code and display page

this is my code:

$role_id = $this->get('session')->get('role_id');
$em = $this->get('doctrine_mongodb')->getManager()->getRepository('AdminBundle:Rolemaster');
$role = $em->createQueryBuilder()->field('rolename')->notEqual('admin')->getQuery()->execute();
    var_dump($role);exit; `

this is the image of output:

Outputimage

Please help me

Upvotes: 1

Views: 243

Answers (1)

iiirxs
iiirxs

Reputation: 4582

This is the expected behavior as executing a query for Doctrine MongoDB query builder, returns a cursor for you to iterate over the results. You can refer to the documentation here.

If you want to get the result as an array you have to use toArray() on the cursor:

$role = $em->createQueryBuilder()
           ->field('rolename')
           ->notEqual('admin')
           ->getQuery()->execute()->toArray();

Upvotes: 1

Related Questions