Hi guys,
I have the following object stored in a MongoDB:
[_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
Now I want to add a new field:
[_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.
...
The 100000XX is a timestamp and the 1.X are the odds
I'm really banging my head off the desk here. Any suggestions much appreciated.
Here's what I have sofar (wrong):
foreach($horses as &$horse)
{
$newdata=array('$set'=>array($horse['odds']=>$price));
$filter=array("marketId"=>$marketId);
$c->update($filter,$newdata);
}