ozahorulia
ozahorulia

Reputation: 10084

Query Builder not working if expression was separated into a few expressions

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?

Upvotes: 0

Views: 230

Answers (1)

Derick
Derick

Reputation: 36774

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();

Upvotes: 1

Related Questions