diff --git a/Model/Datasource/MongodbSource.php b/Model/Datasource/MongodbSource.php index 3ce32e1..c880fb3 100755 --- a/Model/Datasource/MongodbSource.php +++ b/Model/Datasource/MongodbSource.php @@ -889,20 +889,27 @@ public function updateAll(&$Model, $fields = null, $conditions = null) { $fields = $this->setMongoUpdateOperator($Model, $fields); $this->_prepareLogQuery($Model); // just sets a timer - $table = $this->fullTableName($Model); + $table = $this->fullTableName($Model); + if (!is_null($conditions)) { + foreach ($conditions as $key => &$cond ) { + if ($key === $Model->primaryKey) { + $this->_convertId($cond, true); + } + } + } try{ if ($this->_driverVersion >= '1.3.0') { // not use 'upsert' $return = $this->_db ->selectCollection($table) - ->update($conditions, $fields, array("multiple" => true, 'safe' => true)); + ->update($conditions, $fields, array("multi" => true, 'safe' => true)); if (isset($return['updatedExisting'])) { $return = $return['updatedExisting']; } } else { $return = $this->_db ->selectCollection($table) - ->update($conditions, $fields, array("multiple" => true)); + ->update($conditions, $fields, array("multi" => true)); } } catch (MongoException $e) { $this->error = $e->getMessage(); @@ -911,7 +918,7 @@ public function updateAll(&$Model, $fields = null, $conditions = null) { if ($this->fullDebug) { $this->logQuery("db.{$table}.update( :conditions, :fields, :params )", - array('conditions' => $conditions, 'fields' => $fields, 'params' => array("multiple" => true)) + array('conditions' => $conditions, 'fields' => $fields, 'params' => array("multi" => true)) ); } return $return;