Example #1
0
 public function update($entity)
 {
     $id = null;
     foreach (['id', '_id'] as $key) {
         if (isset($entity[$key])) {
             $id = (string) $entity[$key];
             unset($entity[$key]);
         }
     }
     $this->db->selectCollection($this->collection)->update(['_id' => new MongoId($id)], ['$set' => $entity], ['multiple' => true]);
 }
Example #2
0
 /**
  * Set the DB instance
  *
  * @param \Mongo\Db $db
  * @return $this
  */
 public function setDb($db)
 {
     $this->db = $db;
     $this->collection = $db->selectCollection($this->collectionName);
     return $this;
 }