MongoDB に shop というコレクションがあります
shop{
"_id" : "523c1e",
"address" : "100, University Road",
"city" : "xyz",
"contact_name" : "John",
"deals" : [
{
"deal_id" : "524913",
"deal_type" : "Sale",
"deal_description" : "Very good deal",
"start_date" : "2013-09-12",
"end_date" : "2013-09-31"
},
{
"deal_id" : "52491abf6",
"deal_type" : "Sale",
"deal_description" : "Buy 2 jeans, get one free",
"start_date" : "2013-09-20",
"end_date" : "2013-10-31"
}
],
}
mongodb と php を使用して、現在実行中の取引 (現在の日付 '2013-10-01') と _id="523c1e" を見つけたいです。
だから私は得るでしょう、
{
"deal_id" : "52491abf6",
"deal_type" : "Sale",
"deal_description" : "Buy 2 jeans, get one free",
"start_date" : "2013-09-20",
"end_date" : "2013-10-31"
}
このクエリを正しくするのを手伝ってください、
私はこれを試していますが、出力はありません
<?php
date_default_timezone_set('Asia/Kolkata');
$date=date('Y-m-d');
$pro_id='523c1e';
$cursor = $collection->find(array("_id" => "$pro_id",$date => array('$gt' => 'deals.start_date','$lte' => 'deals.end_date')),array("deals" => 1));
foreach($cursor as $document)
{
echo json_encode(array('posts'=>$document));
}
?>
私を助けてください...