1
我只是試圖更新文檔中的一個特定字段,我有一個MongoDB數據庫。更新MongoDB文檔不工作
我有下面的代碼:
$connection = new MongoClient("private");
$collection = $connection->testdb->deliveries;
// Use the ID to generate the actual MongoID
$realmongoid = new MongoId($id);
$cursor = $collection->findOne(array('_id' => $realmongoid));
所以所有的工作完全正常,但是當我嘗試我與此代碼文件中更新特定字段:
$arrayWithDriverInfo = array("filledBy" => $_SESSION['username']);
$cursor->update($arrayWithDriverInfo);
一點也沒有」工作。我收到此消息:致命錯誤:Call to a member function update() on array in...
這是怎麼回事?