当前位置:网站首页>PHP operation mangoDb
PHP operation mangoDb
2022-08-05 09:44:00 【I don't know, it's kinda sucking】
insert(['id' => 1, 'name'=>'test', 'url' => 'csdn.com']);$manager->executeBulkWrite('test.jihe1', $bulk);// Inquire$filter = ['name' => 'test'];$options = ['projection' => ['_id' => 0],'sort' => ['name' => -1],];$query = new MongoDB\Driver\Query($filter, $options);$cursor = $manager->executeQuery('test.jihe', $query);foreach ($cursor as $document) {print_r($document);}// edit$bulk = new MongoDB\Driver\BulkWrite;$bulk->update(['id' => 1],['$set' => ['name' => 'Test 1234']],['multi' => false, 'upsert' => false] #multi means to update only one piece of data, upsert means that if there is no updated record, no insert operation is performed);$writeConcern = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY, 1000);$result = $manager->executeBulkWrite('test.jihe', $bulk, $writeConcern);// delete$bulk = new MongoDB\Driver\BulkWrite;$bulk->delete(['id' => 1], ['limit' => 1]); // when limit is 1, delete the first matching data$bulk->delete(['id' => 2], ['limit' => 0]); // when limit is 0, delete all matching data$writeConcern = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY, 1000);$result = $manager->executeBulkWrite('test.jihe', $bulk, $writeConcern);?>边栏推荐
猜你喜欢

Hundred lines of code launch red hearts, why programmers lose their girlfriends!

After Keil upgrades to AC6, what changes?

Pytorch深度学习快速入门教程 -- 土堆教程笔记(三)

Redis源码解析:Redis Cluster

Science bosses say | Hong Kong rhubarb KaiBin teacher take you unlock the relationship between the matrix and 6 g

dotnet OpenXML parsing PPT charts Getting started with area charts

Example of Noise Calculation for Amplifier OPA855

并发之CAS

express hot-reload

express hot-reload
随机推荐
Excuse me if you want to write data in mysql, with flink - connector - JDBC directly is ok, but I'm in the f
Can MySQL use aggregate functions without GROUP BY?
IO stream articles -- based on io stream to realize folder copy (copy subfolders and files in subfolders) full of dry goods
js graphics operation one (compatible with pc, mobile terminal to achieve draggable attribute drag and drop effect)
程序员的七种武器
Which big guy has the 11G GI and ojvm patches in April or January 2020, please help?
Dry goods!Generative Model Evaluation and Diagnosis
CPU的亲缘性affinity
无题十二
Science bosses say | Hong Kong rhubarb KaiBin teacher take you unlock the relationship between the matrix and 6 g
2022/8/4 考试总结
MySQL使用聚合函数可以不搭配GROUP BY分组吗?
Voice conversion相关语音数据集综合汇总
shell脚本实例
How ali cloud storage database automatically to speed up the loading speed of www.cxsdkt.cn how to set up the case?
leetcode refers to Offer 10- II. Frog jumping steps
PAT乙级-B1019 数字黑洞(20)
Excuse me, guys, is it impossible to synchronize two databases in real time using Flink SQL CDC?
歌词整理
CCVR eases heterogeneous federated learning based on classifier calibration