php--MongoDB的使用

添加

$collection = (new MongoDB\Client)->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',
    ],
]);

猜你喜欢

转载自www.cnblogs.com/peilanluo/p/10503161.html