「revision_no」フィールドが一致しない場合は JSON オブジェクトを mongodb に挿入し、一致する場合は両方のフィールドを更新する次の PHP 関数があります。
function saveJson($data){
$mongo = new Mongo();
$db = $mongo->selectDB("technical");
$db->createCollection("ge",false);
$technical = $db->selectCollection("ge");
$json = json_decode($data['data']);
$count = $technical->count(array('job_id' => $data['job_id'], 'revision_no' => $data['revision_no']));
echo $count;
if($count > 0){
//With just job_id, it returns the correct count
//$technical->update(array('job_id' => $data['job_id']), $json);
$technical->update(array('job_id' => $data['job_id'], 'revision_no' => $data['revision_no']), $json);
}else{
$technical->insert($json);
}
}
問題は、ジョブ ID とリビジョン番号の組み合わせでカウントが機能しないように見えることです。ただし、job_id だけで機能します。誰かが私が間違っているところを教えてもらえますか?