
Untitled
By: a guest on
Aug 7th, 2012 | syntax:
None | size: 0.56 KB | hits: 5 | expires: Never
Storing a document in a different collection - Mongodb with symfony2
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());}
<?php
namespace MyProjectDocument;
use DoctrineODMMongoDBMappingAnnotations as ODM;
/**
* @ODMDocument(
* collection="charlies_posts"
* )
*/
class Post
{
DocumentsUser:
type: document
db: my_db
collection: charlies_post