I have a simple question about the (by the way really great!) Doctrine ODM.
Assume you have a document like:
/**
* @Document
*/
class Test
{
/** @I
The best answer is using hash type. But if for some reason you wantn't use hash
type, you can use EmbeddedDocument feature provided by Doctrine ODM like the documentation says:
If you are using the hash type, values within the associative array are passed to MongoDB directly, without being prepared. Only formats suitable for the Mongo driver should be used. If your hash contains values which are not suitable you should either use an embedded document or use formats provided by the MongoDB driver (e.g. \MongoDate instead of \DateTime).
So, you need to create EmbeddedDocument EmbeddedExample
in AppBundle\Document\EmbeddedExample.php
:
Then, you can use EmbeddedExample
in your Test
document. So the Test.php
file will be similar to this: