当前位置:网站首页>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);?>边栏推荐
- CPU的亲缘性affinity
- 2.4G无线收发模块的应用
- 19. Server-side session technology Session
- leetcode refers to Offer 10- II. Frog jumping steps
- 无题八
- 21 Days of Deep Learning - Convolutional Neural Networks (CNN): Clothing Image Classification (Day 3)
- seata源码解析:TM RM 客户端的初始化过程
- 干货!生成模型的评价与诊断
- PAT乙级-B1019 数字黑洞(20)
- PAT Grade B-B1020 Mooncake(25)
猜你喜欢

交换机端口的三种类型详解与hybrid端口实验

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

hcip BGP 增强实验

Egg framework usage (2)

Custom filters and interceptors implement ThreadLocal thread closure

MySQL advanced (twenty-seven) database index principle

Two-table query average grouping in sql server

egg框架使用(二)

Pycharm 常用外部工具

轩辕实验室丨欧盟EVITA项目预研 第一章(四)
随机推荐
线程之Happens-before规则
CCVR基于分类器校准缓解异构联邦学习
egg框架使用(二)
What is the function of the regular expression replaceAll() method?
hcip BGP enhancement experiment
Example of Noise Calculation for Amplifier OPA855
js 图形操作一(兼容pc、移动端实现 draggable属性 拖放效果)
There is only one switch, how to realize the nqa of master-slave automatic switching
2.4G无线收发模块的应用
无题十二
19.服务器端会话技术Session
leetcode: 529. Minesweeper Game
Oracle临时表空间作用
无题十四
Creo 9.0 基准特征:基准坐标系
Going to book tickets tomorrow, ready to go home~~
MySQL使用聚合函数可以不搭配GROUP BY分组吗?
CCVR eases heterogeneous federated learning based on classifier calibration
Voice conversion相关语音数据集综合汇总
PAT Class B-B1019 Digital Black Hole (20)