How to remove multiple documents in Doctrine MongoDB ODM -


how can remove multiple documents in doctrine mongodb odm? in php class should able using following code:

 $db->collection->remove(array("age" => 18)); 

how can in doctrine mongo odm?

you have 2 options. using documentmanager, can request collection given class. return doctrine\mongodb\collection instance, wraps base mongocollection support logging , events. underlying mongocollection available if want it, too:

$collection = $dm->getdocumentcollection('documents\user'); $collection->remove(array('age' => 18));  // use raw mongocollection bypass logging , events $mongocollection = $collection->getmongocollection(); $mongocollection->remove(array('age' => 18)); 

alternatively, can use query builder api:

$qb = $dm->createquerybuilder('documents\user'); $qb->remove()     ->field('age')->equals(18)     ->getquery()     ->execute(); 

if stop @ getquery(), can use debug() method on returned query object see doctrine execute against database.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -