0

我有以下 mongodb 结构

{
    "_id" : 18536,
    "billing" : {
        "patientinfo" : {                        
                "patient_id" : "120196"                        
        },
        "billinginfo" : {
                "billingid" : "B1"                       
        },
        "receiptinfo" : [ ]
    }
}

我想插入数组一旦再次插入一个值,我必须插入另一个值,例如("receipt_id"=>"R1"):。 我尝试了以下不起作用的代码:receiptinfo("receipt_id"=>"R2")

$updatereceipt =$collection->update(
    array('_id' => (int)$id,'billing.receiptinfo.receipt_id'=>$receiptid),
    array('$set' => array('billing.receiptinfo'=>array('receipt_id' => $receiptid))),           
    array("upsert"=>true)
);
4

0 回答 0