2

I use doctrine ODM to persist and load documents from my Mongo DB. I followed this guide: https://doctrine-mongodb-odm.readthedocs.org/en/latest/tutorials/getting-started.html

Following this guide all documents get stored in the database "doctrine" by default. But what if I have my own database? How do I select the database? I couldn't find anything use in the documentation nor google.

Community
  • 1
  • 1
tester
  • 3,977
  • 5
  • 39
  • 59

1 Answers1

2

you can use the Configuration class.

$config->setDefaultDB('mydbname');
mpm
  • 20,148
  • 7
  • 50
  • 55
  • That works, thanks. Maybe one more question. I have a document with the following id: `"_id": ObjectId("5345a88b22272deec6db2cca")` If I now do `$dm->find('Document', '5345a88b22272deec6db2cca');` I only get null. Isn't it the id? – tester Apr 09 '14 at 20:09