MongoDB - PHP sorgusu ile yardımcı

0 Cevap php

Ben bir MongoDB aşağıdaki nesneyi kaydettikten:

[_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

Şimdi yeni bir alan eklemek istiyorum:

[_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 bir zaman damgası ve 1.X oran

Ben gerçekten burada masadan başımı beceriyor ediyorum. Herhangi bir öneriniz çok takdir.

İşte sofar (yanlış) ne var:

foreach($horses as &$horse)
{
    $newdata=array('$set'=>array($horse['odds']=>$price));
    $filter=array("marketId"=>$marketId);
    $c->update($filter,$newdata);
}

0 Cevap