我试着使用的MongoDB和Symfony2的存储在不同的集合的文档 - MongoDB的与Symfony2的
这是我的控制器谁设置文档进DB存储在不同的集合的文档。
public function createAction(){
$post = new Post();
$post->setUrl('A Foo Bar');
$post->setTitle('asdf');
$dm = $this->get('doctrine.odm.mongodb.document_manager');
$dm->persist($post);
$dm->flush();
return new Response('Created post id '.$post->getId());}
正如你所看到的,这是DoctrineMongoDBBundle
的官方文档的例子,但问题是,默认情况下,它创建的文档转换成一个命名为类集合,在我的情况是邮政(),所以集合名称是Post。我想将文档保存到一个名为charlies_posts的集合或任何字符串作为变量。