Question

I'm woking with the last version of the Doctrine ODM (Mongodb).

This works:

$items = $om->createQueryBuilder($itemClass)
    ->field('active')->equals(true)
    ->getQuery()->execute();

This doesn't work:

$items = $om->createQueryBuilder($itemClass)
    ->field('active')->equals(true);
$items->getQuery()->execute();

I need it to be working If I want to add dynamic parameters. Both query builders executes exactly the same query (shown in the profiler).

Am I doing something wrong or thi is a doctrine bug?

Was it helpful?

Solution

It looks like you simply forgot to assign the result of execute() back to $items:

$items = $om->createQueryBuilder($itemClass)
            ->field('active')->equals(true);
$items = $items->getQuery()->execute();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top