当前位置:网站首页>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);?>边栏推荐
- 开源一夏|OpenHarmony如何查询设备类型(eTS)
- ECCV 2022 Oral Video Instance Segmentation New SOTA: SeqFormer & IDOL and CVPR 2022 Video Instance Segmentation Competition Champion Scheme...
- 手写柯里化 - toString 理解
- Analysis and practice of antjian webshell dynamic encrypted connection
- Tanabata romantic date without overtime, RPA robot helps you get the job done
- 【zeno】为zeno增加子模块/新节点的最小化的例子
- 5.部署web项目到云服务器
- PAT Class B-B1019 Digital Black Hole (20)
- Pytorch深度学习快速入门教程 -- 土堆教程笔记(三)
- js 图形操作一(兼容pc、移动端实现 draggable属性 拖放效果)
猜你喜欢

微服务 技术栈

七夕浪漫约会不加班,RPA机器人帮你搞定工作

MySQL内部函数介绍

Two-table query average grouping in sql server

IDEA performs the Test operation, resulting in duplicate data when data is inserted

js 图形操作一(兼容pc、移动端实现 draggable属性 拖放效果)

Advanced usage of C language

How to realize the short press and long press detection of the button?

ECCV 2022 Oral 视频实例分割新SOTA:SeqFormer&IDOL及CVPR 2022 视频实例分割竞赛冠军方案...

Example of Noise Calculation for Amplifier OPA855
随机推荐
egg框架使用(一)
交换机端口的三种类型详解与hybrid端口实验
Analysis and practice of antjian webshell dynamic encrypted connection
欧盟 | 地平线 2020 ENSEMBLE:D2.13 SOTIF Safety Concept(上)
百行代码发射红心,程序员何愁命不中女朋友!
MySQL内部函数介绍
MySQL使用聚合函数可以不搭配GROUP BY分组吗?
Example of Noise Calculation for Amplifier OPA855
Excuse me if you want to write data in mysql, with flink - connector - JDBC directly is ok, but I'm in the f
5.部署web项目到云服务器
Hundred lines of code launch red hearts, why programmers lose their girlfriends!
开源一夏|OpenHarmony如何查询设备类型(eTS)
浅析WSGI协议
IDEA执行Test操作导致数据插入时出现了重复数据
轩辕实验室丨欧盟EVITA项目预研 第一章(四)
Tanabata romantic date without overtime, RPA robot helps you get the job done
无题十二
Handwriting Currying - toString Comprehension
Qiu Jun, CEO of Eggplant Technology: Focus on users and make products that users really need
The technological achievements of Shanghai Konan were selected into the "2021 Shanghai Network Security Industry Innovation Research Achievement Catalog" by the Municipal Commission of Economy and Inf