Answer the question
In order to leave comments, you need to log in
How to display subdocument data in mongodb?
Hello.
Can you tell me how to display the data of the attached document?
For example, I need to get category products:
{
"_id" : ObjectId("11b97aa654bce41356002559"),
"name" : "Test",
"images" : "test.png",
"products" : [
{
"_id" : ObjectId("00b12aa654bce41356002559"),
"name" : "Product 0",
"price" : "$1 000 000 000",
}
]
}
$products = Products::find() -> where(['hit' => '1']) -> limit(6) -> all();
return $this -> render('index', compact('products'));
$products = Categories::find() -> where(['products.hit' => '1']) -> limit(6) -> all();
Answer the question
In order to leave comments, you need to log in
www.yiiframework.com/doc-2.0/yii-mongodb-activeque...
www.yiiframework.com/doc-2.0/yii-mongodb-activerec...
www.yiiframework.com/doc-2.0/yii-mongodb- collection...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question