当前位置:网站首页>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)
- 【零基础玩转BLDC系列】无刷直流电机无位置传感器三段式启动法详细介绍及代码分享
- 汇编语言(8)x86内联汇编
- Creo 9.0 基准特征:基准平面
- leetcode points to Offer 10- I. Fibonacci sequence
- matcher中find,matches,lookingAt匹配字符串的不同之处说明
- eKuiper Newsletter 2022-07|v1.6.0:Flow 编排 + 更好用的 SQL,轻松表达业务逻辑
- 韦东山 数码相框 项目学习(六)tslib的移植
- IO流篇 -- 基于io流实现文件夹拷贝(拷贝子文件夹及子文件夹内文件)满满的干货
- 七夕浪漫约会不加班,RPA机器人帮你搞定工作
猜你喜欢

Advanced usage of C language

Creo 9.0 基准特征:基准坐标系

There is only one switch, how to realize the nqa of master-slave automatic switching

哪位大佬有20年4月或者1月的11G GI和ojvm补丁呀,帮忙发下?

ECCV 2022 Oral Video Instance Segmentation New SOTA: SeqFormer & IDOL and CVPR 2022 Video Instance Segmentation Competition Champion Scheme...

shell脚本实例

Oracle temporary table space role

Assembly language (8) x86 inline assembly

Dry goods!Generative Model Evaluation and Diagnosis

dotnet OpenXML 解析 PPT 图表 面积图入门
随机推荐
mysql进阶(二十七)数据库索引原理
express hot-reload
Example of Noise Calculation for Amplifier OPA855
5. Deploy the web project to the cloud server
2022-08-01 Review the basic binary tree and operations
无题十
leetcode refers to Offer 10- II. Frog jumping steps
express hot-reload
无题一
2.4G无线收发模块的应用
Creo 9.0 基准特征:基准坐标系
Is there a problem with writing this?How to synchronize data in sql-client
js 图形操作一(兼容pc、移动端实现 draggable属性 拖放效果)
无题三
leetcode: 529. Minesweeper Game
PAT Class B-B1019 Digital Black Hole (20)
蚁剑webshell动态加密连接分析与实践
PAT Grade B-B1020 Mooncake(25)
明天去订票,准备回家咯~~
营销建议 | 您有一份八月营销月历待查收! 建议收藏 !