我使用Doctrine 2 ODM \ MongoDB(这个和依赖关系全部来自GIT)+ PHP Mongo扩展(v1.1.4)+ Mongo(v1.8.3 x64 latest)
在某些情况下,当我更改实体时,它不会得到更新
在嵌入式实体中,我有一个对它的父级的后引用,以解决http://groups.google.com/group/doctrine-dev/browse_thread/thread/016422b2cc9dcec9?pli=1(如何在嵌入式文档中获取父文档?)而不使用像UnitOfWork这样的内部功能 - 这可能或可能不相关,我不知道......我希望不会(我的问题到目前为止它是否在IRC上没有答案)
然而,一个Character的嵌入式文档中的单个更改会触发这些查询(应该只与它相关,在它之前已经有了刷新,并且在更改之前再次设置的标记上的记录器内部存在条件)
记录器转储:
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)
}
初始化代码:http://pastebin.com/1dKagqry
“components.destructible.hp”=> 99.28706276 是核心部分 - >但这种变化从未反映在数据库中
我可以在哪里进一步搜索,或者我该怎么做才能解决此问题 谢谢
答案 0 :(得分:0)
这很尴尬,但问题是我希望将EmbeddedDocuments编入索引(如关联数组)......但是这是在一个实际的Doctrine维护属性上完成的,所以它触发了重新推送EmbeddedDocument,丢弃了更改< / p>
答案 1 :(得分:-1)
$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();