MongoDB query results are converted to an array
/ / data synchronization
Public function data_Sync () {
$filter = []; $options = ['projection' = > [' _ id' = > 0]]; / / remove _ id / / query data $query = new\ MongoDB\ Driver\ Query ($filter, $options); $cursor = $this- > mongodb- > executeQuery ('test.mydata', $query); $cursor = $cursor- > toArray (); / / tp5 function transfer foreach ($cursor as $key= > $value) {$value = ((array) $value) / / directly force the array type $res = Db::name ('sreadreport')-> insert ($value);}}