فهرست منبع

Adding fix on update

Paolo Libertini 6 سال پیش
والد
کامیت
271503a1ec
1فایلهای تغییر یافته به همراه5 افزوده شده و 2 حذف شده
  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){
     protected function ___load($_value, $_attributeName = NULL){
         if(is_null($_attributeName)){
         if(is_null($_attributeName)){
+            $this->loadKey = ['_id' => new MongoId($_value)];
             return parent::find($_value);
             return parent::find($_value);
         } else {
         } else {
+            $this->loadKey = array($_attributeName => $_value);
             return parent::fetchOne(array($_attributeName => $_value));
             return parent::fetchOne(array($_attributeName => $_value));
         }
         }
     }
     }
@@ -412,8 +414,9 @@ class Mooses_AbstractMongo extends Mooses_Mongodb_Mongo_Document {
         return $result;
         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;
         return $_return;
     }
     }