Get the App
SLTechnology News&Howtos  ›  Database  › 

MongoDB query results are converted to an array

Shulou Source: shulou.com Published: 2022-06-01 22:44:54 11月06日 Update

/ / 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);}}

Tags: Data queries functions fields types synchronization arrays results Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Huawei Xiaomi macOS Shulou Information