当前位置:网站首页>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);?>边栏推荐
- Seata source code analysis: initialization process of TM RM client
- C语言的高级用法
- Voice conversion相关语音数据集综合汇总
- CCVR基于分类器校准缓解异构联邦学习
- Neuron Newsletter 2022-07|新增非 A11 驱动、即将支持 OPC DA
- 无题十二
- Why do I recommend using smart async?
- Open Source Summer | How OpenHarmony Query Device Type (eTS)
- Pytorch深度学习快速入门教程 -- 土堆教程笔记(三)
- Pytorch Deep Learning Quick Start Tutorial -- Mound Tutorial Notes (3)
猜你喜欢

Why do I recommend using smart async?

Qiu Jun, CEO of Eggplant Technology: Focus on users and make products that users really need

为什么我推荐使用智能化async?

【LeetCode】623. Add a row to the binary tree

偏向锁/轻量锁/重级锁锁锁更健康,上锁解锁到底是怎么完成实现的

hcip BGP 增强实验

【AGC】增长服务1-远程配置示例

dotnet OpenXML 解析 PPT 图表 面积图入门

开源一夏|OpenHarmony如何查询设备类型(eTS)

Creo 9.0 基准特征:基准点
随机推荐
Four years of weight loss record
上海控安技术成果入选市经信委《2021年上海市网络安全产业创新攻关成果目录》
Creo 9.0 基准特征:基准点
汇编语言(8)x86内联汇编
openpyxl to manipulate Excel files
What is the function of the regular expression replaceAll() method?
歌词整理
Egg framework usage (2)
Seata source code analysis: initialization process of TM RM client
长达四年的减肥记录
dotnet OpenXML parsing PPT charts Getting started with area charts
leetcode: 529. Minesweeper Game
Wei Dongshan Digital Photo Frame Project Learning (6) Transplantation of tslib
Weekly Report 2022-8-4
Two-table query average grouping in sql server
Voice conversion相关语音数据集综合汇总
19. Server-side session technology Session
CCVR eases heterogeneous federated learning based on classifier calibration
EU | Horizon 2020 ENSEMBLE: D2.13 SOTIF Safety Concept (Part 2)
Why are RELTABLESPACE values 0 for many tables displayed in sys_class?