Ver código fonte

Adding fix on update

Paolo Libertini 6 anos atrás
pai
commit
271503a1ec
1 arquivos alterados com 5 adições e 2 exclusões
  1. 5 2
      lib/Mooses/AbstractMongo.php

+ 5 - 2
lib/Mooses/AbstractMongo.php

@@ -381,8 +381,10 @@ class Mooses_AbstractMongo extends Mooses_Mongodb_Mongo_Document {
 
     protected function ___load($_value, $_attributeName = NULL){
         if(is_null($_attributeName)){
+            $this->loadKey = ['_id' => new MongoId($_value)];
             return parent::find($_value);
         } else {
+            $this->loadKey = array($_attributeName => $_value);
             return parent::fetchOne(array($_attributeName => $_value));
         }
     }
@@ -412,8 +414,9 @@ class Mooses_AbstractMongo extends Mooses_Mongodb_Mongo_Document {
         return $result;
     }
 
-    public function updateData(){
-        $_return = $this->update($this->loadKey, array('$set' => $this->_dataUpdate));
+    public function updateData($_criteria = false){
+        $_criteria = $_criteria ?: $this->loadKey;
+        $_return = $this->update($_criteria, array('$set' => $this->_dataUpdate));
         return $_return;
     }