소스 검색

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){
         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;
     }