I have connected my php web app to mongodb with the help of codeigniter driver. Trying to inserting multiple json elements into database as below.
"ticket" : [
{
"problem" : "testing",
"time_taken" : "5 hrs",
"number_of_visits" : "7",
"expenses" : {
"amount" : "2000",
"distance_travelled" : "4 km"
}
},
{
"problem" : "testing",
"time_taken" : "5 hrs",
"number_of_visits" : "4",
"expenses" : {
"amount" : "2500",
"distance_travelled" : "5 km"
}
}
]
What is the query I have to use for this?
$this->mongo_db->where('_id', new MongoId($id))->push("ticket",$data)->update('engineer');
This is the query I'm using for inserting multiple array values in mongodb codeigniter.