/** * Atomic, in-place update method. * * @since v1.3.6 * @param EMongoModifier $modifier updating rules to apply * @param EMongoCriteria $criteria condition to limit updating rules * @return boolean */ public function updateAll($modifier, $criteria = null) { Yii::trace(get_class($this) . '.updateAll()', 'ext.MongoDb.EMongoDocument'); if ($modifier->canApply === true) { if ($this->getMongoDBComponent()->enableProfiling) { Yii::beginProfile(get_class($this) . '.updateAll(' . json_encode($criteria->getConditions()) . ')', 'ext.MongoDb.EMongoDocument'); } $this->applyScopes($criteria); if (version_compare(Mongo::VERSION, '1.0.5', '>=') === true) { $result = $this->getCollection()->update($criteria->getConditions(), $modifier->getModifiers(), array('fsync' => $this->getFsyncFlag(), 'safe' => $this->getSafeFlag(), 'upsert' => false, 'multiple' => true)); } else { $result = $this->getCollection()->update($criteria->getConditions(), $modifier->getModifiers(), array('upsert' => false, 'multiple' => true)); } if ($this->getMongoDBComponent()->enableProfiling) { Yii::endProfile(get_class($this) . '.updateAll(' . json_encode($criteria->getConditions()) . ')', 'ext.MongoDb.EMongoDocument'); } return $result; } else { return false; } }
/** * @param MtBaseMongoModel $model * @param bool $useModel * @return array */ public function getConditions(MtBaseMongoModel $model = NULL, $useModel = TRUE) { if ($useModel and $model = $model ?: $this->getModel()) { $conditions = $model->getConditions($this); } else { $conditions = parent::getConditions(); } return $conditions; }
public function getConditions(EMongoCriteria $criteria) { return $this->_walkConditions($criteria->getConditions(NULL, FALSE)); }
public function findAsArray(EMongoCriteria $criteria = NULL) { return $this->getCollection()->findOne($criteria->getConditions(), $criteria->getSelect()); }