dedemao/mongodb
Composer 安装命令:
composer require dedemao/mongodb
包简介
A simple mongoDB library for PHP7
README 文档
README
A simple mongoDB library for PHP7
Installation
The preferred method of installing this library is with Composer by running the following from your project root:
$ composer require dedemao/mongodb
How to use
Demo 1:
require 'vendor/autoload.php';
$conf['host'] = '127.0.0.1';
$conf['port'] = '27017';
$conf['user'] = '';
$conf['pass'] = '';
$conf['dbname'] = 'test';
$conf['collectionname'] = 'demo';
$mongo = new dedemao\mongodb\MongoDBHelper($conf);
Demo 2:
include "src/mongoDBHelper.php";
$conf['host'] = '127.0.0.1';
$conf['port'] = '27017';
$conf['user'] = '';
$conf['pass'] = '';
$conf['dbname'] = 'test';
$conf['collectionname'] = 'demo';
$mongo = new dedemao\mongodb\MongoDBHelper($conf);
CURD:
//Creat:
$result = $mongo->insertOne(['name'=>'John','age'=>'18']);
$result = $mongo->insertMany([['name'=>'John','age'=>'18'],['name'=>'Jay','age'=>'20']]);
//Read:
$row = $mongo->find(['age'=>'18']);
$row = $mongo->findOne(['name'=>'John']);
//Update:
$result = $mongo->update(['name'=>'John'],['$set' => ['age' => '30']]);
//Delete
$result = $mongo->delete(['name'=>'John']);
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-05-16