I try to add some values in existing Collection using Update but I retrieve just just the last value:
An example:
When I try to add to this document in MongoDB an array with different values like this:
$test=
array("one"=>"Item1","two"=>"Item2","three"=>"Item3","four"=>"Item4",
"five"=>"Item5","six"=>"Item6");
$collectionMeasurements->insert($test);
for($i=0;$i<5;$i++){
$collectionMeasurements->update(
array("one" => "Item1"),
array('$set' => array('new' => $i)),
array("multiple" => true)
);
}
I get as results:
Array
(
[_id] => MongoId Object
(
)
[five] => Item5
[four] => Item4
[new] => 4
[one] => Item1
[six] => Item6
[three] => Item3
[two] => Item2
)
I would like to get something like that:
Array
(
[_id] => MongoId Object
(
)
[five] => Item5
[four] => Item4
[new] => array(1,2,3,4)
[one] => Item1
[six] => Item6
[three] => Item3
[two] => Item2
)
Any suggestion of how I can accomplish this please? Thanks!!!