2011-11-26 82 views
0

我嘗試新的陣列集合中添加到現有的文件:蒙戈+ PHP:更新文檔集合在一個新的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); 

但它不工作...我失去的東西這裏?

+0

能在你面前,並執行此代碼後,添加到該文件的問題轉儲? – mephisto123

回答

0

我想通了,我需要一個「多」的文件更新條件添加到更新命令的末尾:

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

你沒有提到你有多個文件:)無論如何,很高興你找到了解決方案。 – mephisto123

+0

是的,那是不清楚的,對不起:) – alyx