Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 7th, 2012  |  syntax: None  |  size: 0.56 KB  |  hits: 5  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Storing a document in a different collection - Mongodb with symfony2
  2. public function createAction(){
  3. $post = new Post();
  4. $post->setUrl('A Foo Bar');
  5. $post->setTitle('asdf');
  6. $dm = $this->get('doctrine.odm.mongodb.document_manager');
  7. $dm->persist($post);
  8. $dm->flush();
  9. return new Response('Created post id '.$post->getId());}
  10.        
  11. <?php
  12.  
  13. namespace MyProjectDocument;
  14.  
  15. use DoctrineODMMongoDBMappingAnnotations as ODM;
  16.  
  17. /**
  18.  * @ODMDocument(
  19.  *     collection="charlies_posts"
  20.  * )
  21.  */
  22. class Post
  23. {
  24.        
  25. DocumentsUser:
  26.   type: document
  27.   db: my_db
  28.   collection: charlies_post