我正在尝试搜索对特定数据项进行筛选的 MongoDB 数据库。具体来说,我想要 USA = PG-13 作为我的过滤器。
如何提出请求:获取电影,其中美国 MPAA = PG-13?
采集国家:
{
"_id": ObjectId("4fd79ec34c9fda9d05000080"),
"en": "USA"
}
{
"_id": ObjectId("4fd79ec34c9fda9d0500007f"),
"en": "Hong Kong"
}
合集电影:
{
"_id": ObjectId("4fd79ec34c9fda9d05000081"),
"movieId": {
"imdb": "0848228"
},
"movieTitle": "The Avengers",
"movieYearSpan": {
"start": "2012",
"end": "2012"
},
"movieType": "Movie",
"movieMpaa": {
"verdict": "Rated PG-13",
"0": {
"mpaa": "IIA",
"country": ObjectId("4fd79ec34c9fda9d0500007f")
},
"1": {
"mpaa": "PG-13",
"country": ObjectId("4fd79ec34c9fda9d05000080")
}
}
}
我试图首先获得美国的身份证。
$cursorCountry = $collectionCountry->find(array("en" => "USA"));
$idCountry = $cursorCountry->getNext();
$_id = $idCountry["_id"];
$cursorMovie = $collectionMovie->find(array("movieMpaa.country" => $_id, "movieMpaa.mpaa" => "PG-13"));
不工作!那么如何提出请求呢?要获得电影,美国的 MPAA = PG-13?