I have a problem with a query from a repository class.
I need this result for mongodb
db.RequestsPictures.find({
"picture.$id": {
"$in":[
ObjectId("5013a65dd1853eb02c000000"),
ObjectId("5013a47dd1853e4919000001")
]
}
}).sort([ ]);
This query works fine in MongoDB but I don’t know how to write this query with the QueryBuilder.
If I test this code – doctrine will set bad quotes
$ids = array(
'ObjectId("5013a65dd1853eb02c000000")',
'ObjectId("5013a47dd1853e4919000001")'
);
$ids = implode(',', $ids);
return $this->createQueryBuilder()
->field('picture.$id')
->in(array($ids))
->getQuery()
->execute()
->toArray();
The result of this code:
db.RequestsPictures.find({
"picture.$id": {
"$in": [
"ObjectId("5013a65dd1853eb02c000000"),
ObjectId("5013a47dd1853e4919000001")"
]
}
}).sort([ ]);
The quotes after [ and before ] are needless.
So can you tell me how can I disable the auto quotes in the QueryBuilder?
The solution: