Mongo + PHP:用一个新的数组更新集合中的文档


Mongo + PHP: Updating Documents in a collection with a new Array

我正在尝试向集合中的现有文档添加新数组:

    $lat = '38.9586307';
    $lon = '-77.3570028';
    $location = 'office';
    $latLong = array($lat,$lon);
    $newdata = array('$set' => array('latLong' => $latLong));
    $collection->update(array('location' => $location), $newdata);

但它不工作…我错过什么了吗?

我想明白了,我需要在update命令的末尾添加一个"multiple"文档更新条件:

$collection->update(array('location' => $location), $newdata, array("multiple" => true));