0
我有收集與embedMany場「屬性」主義ODM - 由embedMany收藏單位獲得實體
{
"title": "Castle in Scotland",
"properties": {
"0": {
"_id": NumberInt(13),
"propType": {
"$ref": "listing_property_types",
"$id": NumberInt(9),
"$db": "real_estate"
},
"propOption": {
"$ref": "listing_property_options",
"$id": NumberInt(13),
"$db": "real_estate"
}
},
"1": {
"_id": NumberInt(15),
"propType": {
"$ref": "listing_property_types",
"$id": NumberInt(10),
"$db": "real_estate"
},
"propOption": {
"$ref": "listing_property_options",
"$id": NumberInt(15),
"$db": "real_estate"
}
}
}
如何建立查詢,如果我想獲得實體哪裏有屬性格式與propType的$ id = 9,propOption。 = 13
我試試這個
$builder = $this->createQueryBuilder()->select();
foreach ($propertiesArr as $propTypeId => $propOptId) {
if (intval($propTypeId) > 0 && intval($propOptId) > 0) {
$builder->addOr(
$builder->expr()
->field('properties.propType.$id')->equals($propTypeId)
->field('properties.propOption.$id')->equals($propOptId)
);
}
}
}
,但它不工作