我在 mongo db 集合中有以下内容,
{ "_id" : ObjectId("5052f343381ef8bc10000011"), "first_name" : "Tadataka", "midle_name" :
"", "last_name" : "Yamada", "title" : "Independent Director", "biogra
phy" : "Dr. Tadataka Yamada, M.D., is Independent Director of Agilent Technologi
es Inc., ", "rank" : " ", "department" : " ", "current" : "true", "company_id" : ObjectId("50072714b4a6deba100051d3"
) } }
当我尝试为几个字段更新上述内容并插入新字段(如果不存在)时,现有字段会被覆盖。这是我的代码,
$mycollection->update(array("_id" => $id), array('$set' => array("first_name" => $first_name, "updated_at" => $uat));
我得到的结果是
{ "_id" : ObjectId("5052f343381ef8bc10000011"), "first_name" : "Tadataka", "updated_at" : 134567894 }
不是只更新值,而是我的整个内容被覆盖,我错过了。?