我在MongoDB中有一个数据模型,我可以通过本机MongoDB查询成功查询.但是我无法使用Doctrine MongoDB ODM的Query Builder API表达它们.
这就是我的模型在MongoDB中的外观(这是一些JSON代码示例):
{ "name": "ArticleName",
"features": {
{ "type": "color",
...
"values": {
{ "value": "RED",
"label": "red",
....
},
{ "value": "GREEN",
"label": "green" }
}
},
{ "type": "width",
"values": {
{ "value": "40"}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想通过搜索不同的特征值组合来查找文章,例如我想找到一个color = green和width = 40的文章.
但是,我无法使用Doctrine MongoDB ODM Query Builder API构建查询**?这是我试过的:
# Document/ArticleRepository.php
$features = array('color'=>'RED', 'width'=>'40');
$qb = $this->createQueryBuilder('CatalogBundle:Article'); // I use symfony 2
foreach ($features as $type => $value)
{ …Run Code Online (Sandbox Code Playgroud)