这是我简单的Php。
$manager = new MongoDB\Driver\Manager("mongodb://localhost:27017");
$bulk = new MongoDB\Driver\BulkWrite;
我在变量$obj = file_get_contents("link google api")
中有这个数组Json
https://pastebin.com/zPA1r0Vs
存在一种直接在mongodb中保存$ obj的方法吗?
$bulk->insert($obj); (this is line 9)
$manager->executeBulkWrite('db.invoicing', $bulk); (this is line 10)
这是错误:
Warning: MongoDB\Driver\BulkWrite::insert() expects parameter 1 to be array, string given in /var/www/html/php/php_info.php on line 9
Fatal error: Uncaught MongoDB\Driver\Exception\InvalidArgumentException: Cannot do an empty bulk write in /var/www/html/php/php_info.php:10 Stack trace: #0 /var/www/html/php/php_info.php(10): MongoDB\Driver\Manager->executeBulkWrite('db.invoicing', Object(MongoDB\Driver\BulkWrite)) #1 {main} thrown in /var/www/html/php/php_info.php on line 10