php--MongoDB的使用

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php--MongoDB的使用相关的知识,希望对你有一定的参考价值。

添加

$collection = (new MongoDBClient)->test->users;

// 增加一条
$insertOneResult = $collection->insertOne([
    'username' => 'admin',
    'email' => '[email protected]',
    'name' => 'Admin User',
]);

// 增加多条
$insertManyResult = $collection->insertMany([
    [
        'username' => 'admin',
        'email' => '[email protected]',
        'name' => 'Admin User',
    ],
    [
        'username' => 'test',
        'email' => '[email protected]',
        'name' => 'Test User',
    ],
]);

以上是关于php--MongoDB的使用的主要内容,如果未能解决你的问题,请参考以下文章

php mongodb扩展 其他扩展也类似

markdown 使用pecl安装php mongodb驱动程序

NOSQL MongoDB 注入——本质上还是和sql注入是类似的

PHP MongoDB 使用 MongoId Object _id 查询一条记录

核心警告:模块'mongodb'已经加载

php mongodb 多个服务器 replset的问题