Hi there,

I seem to have stumbled on an issue that may be related to no flushing 
objects properly so I'm hoping to gain some insight here using Doctrine 
Mongo ODM in PHP.

Using the query builder I create a query where I update multiple objects:

$qb = $documentManager->createQueryBuilder("...");
$qb->update()
    ->multiple(true)
    ->field('ancestor_id')->equals('123')
    ->field('stuff')->push("hello world")
    ->getQuery()
    ->execute();

$documentManager->flush();

// data has been saved, update (this was verified by looking directly in 
mongo db)

$qb = $documentManager->createQueryBuilder("...");
$cursor = $qb->find()
    ->field('id')->equals('idOfObjectThatWasUpdated')
    ->getQuery()
    ->execute();

foreach ($cursor as $obj) {
    var_dump($obj->getStuff());
}


Now, the expectation var_dump is that I see "hello world" in the object 
that was update. I have verified that the $qb->update()->multiple(true)... 
does in fact work. However, $documentManager->flush() doesn't seem flush 
that query since the subsequent simple query to get an object that was 
update with the multiple query does not have the change registered.

My question is, am I missing something regarding update()->multiple(true) 
queries? I know this is an issue with update()->multiple(true) because if I 
convert this to a query where I "foreach" each object that needs to be 
updated instead, then $documentManager->flush() does in fact flush the 
changes and so it's available for me to query immediately after.

I appreciate any input on this.

Thanks,

Nic

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to