当前位置:网站首页>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);?>
边栏推荐
猜你喜欢
MySQL advanced (twenty-seven) database index principle
基于 Kubernetes 的微服务项目整体设计与实现
leetcode: 529. Minesweeper Game
自定义过滤器和拦截器实现ThreadLocal线程封闭
Creo 9.0 基准特征:基准平面
【zeno】为zeno增加子模块/新节点的最小化的例子
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
Qiu Jun, CEO of Eggplant Technology: Focus on users and make products that users really need
七夕浪漫约会不加班,RPA机器人帮你搞定工作
IDEA执行Test操作导致数据插入时出现了重复数据
随机推荐
自定义过滤器和拦截器实现ThreadLocal线程封闭
Wei Dongshan Digital Photo Frame Project Learning (6) Transplantation of tslib
IO stream articles -- based on io stream to realize folder copy (copy subfolders and files in subfolders) full of dry goods
Creo 9.0 基准特征:基准点
Does flink cdc support synchronization from oracle dg library?
无题十
Qiu Jun, CEO of Eggplant Technology: Focus on users and make products that users really need
营销建议 | 您有一份八月营销月历待查收! 建议收藏 !
Egg framework usage (2)
放大器OPA855的噪声计算实例
手把手教你纯c实现异常捕获try-catch组件
长达四年的减肥记录
Creo 9.0 基准特征:基准平面
2022-08-01 Review the basic binary tree and operations
Tanabata romantic date without overtime, RPA robot helps you get the job done
leetcode 剑指 Offer 10- I. 斐波那契数列
程序员的七种武器
openpyxl操作Excel文件
Why do I recommend using smart async?
CCVR eases heterogeneous federated learning based on classifier calibration