开发者

MongoDB does not get updated

I use Doctrine 2 ODM\MongoDB (this and dependencies all latest from GIT) + PHP Mongo extension (v1.1.4) + Mongo (v1.8.3 x64 latest)

In several cases it happens that when I change an entity, it does not get updated

In an embedded entity I have a back reference to it's parent, to solve http://groups.google.com/group/doctrine-dev/browse_thread/thread/016422b2cc9dcec9?pli=1 (How to get parent document inside embedded document?) without using internal functionalities like UnitOfWork - this MAY or MAY NOT be relevant, I do not know... I would hope that not (my question whether it could went unansw开发者_如何转开发ered on the IRC so far)

However a single change in one of Character's embedded documents triggers these queries (should really be relevant only to it, there's been flush before it and a condition inside the logger on the flag that was set again right before the change)

Logger dump:

array(6) {
   "update" => TRUE
   "query" => array(1) {
      "_id" => MongoId(1) {
         "$id" => "4e3143be662c32400d000006" (24)
      }
   }
   "newObj" => array(1) {
      "$set" => array(2) {
         "components.destructible.hp" => 99.28706276
         "options.character" => array(3) {
            "$ref" => "characters" (10)
            "$id" => MongoId(1) { ... }
            "$db" => "nuclearRain" (11)
         }
      }
   }
   "options" => array(0) 
   "db" => "someDB" (11)
   "collection" => "characters" (10)
}
array(6) {
   "update" => TRUE
   "query" => array(1) {
      "_id" => MongoId(1) {
         "$id" => "4e553306662c32680800054b" (24)
      }
   }
   "newObj" => array(1) {
      "$set" => array(1) {
         "createdBy" => array(3) {
            "$ref" => "characters" (10)
            "$id" => MongoId(1) { ... }
            "$db" => "nuclearRain" (11)
         }
      }
   }
   "options" => array(0) 
   "db" => "someDB" (11)
   "collection" => "worlds" (6)
}
array(6) {
   "update" => TRUE
   "query" => array(1) {
      "_id" => MongoId(1) {
         "$id" => "4e553306662c32680800054c" (24)
      }
   }
   "newObj" => array(1) {
      "$set" => array(1) {
         "world" => array(3) {
            "$ref" => "worlds" (6)
            "$id" => MongoId(1) { ... }
            "$db" => "nuclearRain" (11)
         }
      }
   }
   "options" => array(0) 
   "db" => "someDB" (11)
   "collection" => "games" (5)
}

Initialization code: http://pastebin.com/1dKagqry

"components.destructible.hp" => 99.28706276 is the core part -> yet this change is never reflected in the DB

  • there is no php error/exception triggered
  • mongo's log shows no errors
  • generally the Mongo and Doctrine\ODM\Mongo runs fine, entities get persisted, updated, deleted...

Where can I search further or what can I do to solve this issue Thank you


It is awkward, but the issue is that I wanted the EmbeddedDocuments indexed (like associative array)... this was however done on an actual Doctrine-maintained property, so it triggered re-pushing the EmbeddedDocument, discarding the changes


 $friend = Zend_Registry::get('doctrine')->getDocumentManager()->createQueryBuilder('App\document\Message')->update()->field('unread')->set(TRUE)->field('viewer_id')->equals(10001)-> getQuery(array('multiple' => true))->execute();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜