Question

I have a collection of users and need to retrieve the users using id and condition enabled=1

my code

$dm = $this->get('doctrine.odm.mongodb.document_manager');
$users = $dm->getRepository('xxxxBundle:User')->find($id);

how it possible like

$users = $dm->getRepository('xxxxBundle:User')->find($id,enabled=1);
Was it helpful?

Solution

this will return collection

$users = $dm->getRepository('xxxxBundle:User')->findBy(array('id' => $id, 'enabled' => 1));

or

$user = $dm->getRepository('xxxxBundle:User')->findOneBy(array('id' => $id, 'enabled' => 1));

to get single user entity

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top