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...
这是怎么回事?