2

查看示例:http ://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/query-builder-api.html

我无法做一个简单的增量。那就是“票”的价值永远不会改变。我的文档 ID ($postID) 是正确的,我可以获取该文档。只是无法增加。为什么 Mongo 的文档如此混乱?

$postID = "5121d0ad253b4af1d8000001";
 $dm = $this->get('doctrine.odm.mongodb.document_manager');
$post = $dm->createQueryBuilder('MainPostsBundle:Post')
->field('id')->equals($postID)
->field('votes')->inc(1)
->getQuery()->execute();
4

1 回答 1

1

findAndModify 两者都做(见http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/find-and-update.html

于 2013-10-29T21:38:12.850 回答