我有以下對象存儲在MongoDB的幫助:MongoDB的 - 用PHP查詢
[_id] => MongoId Object (
)
[horses] => Array (
[0] => Array (
[name] => Youve Been Mowed
[selectionId] => 3004097
)
[1] => Array (
[name] => Rascal In The Mix
[selectionId] => 3460932
)
[2] => Array (
[name] => Clumber Place
[selectionId] => 2986884
)
[3] => Array (
[name] => Pretty Orchid
[selectionId] => 2581717
)
[4] => Array (
[name] => Astrodonna
[selectionId] => 2568095
)
[5] => Array (
[name] => Just Sam
[selectionId] => 2511403
)
[6] => Array (
[name] => Many Welcomes
[selectionId] => 2866423
)
[7] => Array (
[name] => Two Turtle Doves
[selectionId] => 3857873
)
[8] => Array (
[name] => Piquante
[selectionId] => 3372813
)
[9] => Array (
[name] => Nimmys Special
[selectionId] => 3066557
)
)
[marketId] => 101531031
[marketName] => 7f Hcap
現在我想添加一個新的領域:
[_id] => MongoId Object (
)
[horses] => Array (
[0] => Array (
[name] => Youve Been Mowed
[selectionId] => 3004097
[odds] => Array(
10000000 => 1.5
10000020 => 1.6
10000030 => 1.7
)
)
...
etc.
...
的100000XX是一個時間戳和1.X是賠率
我真的把我的頭撞到桌子上。任何建議非常感謝。
這裏是我的聲發射(錯誤):
foreach($horses as &$horse)
{
$newdata=array('$set'=>array($horse['odds']=>$price));
$filter=array("marketId"=>$marketId);
$c->update($filter,$newdata);
}
是的,我也是克里斯蒂娜。 – kristina 2010-07-08 16:18:51