PHP Velho Oeste 2024

获取集合实例

获取一个集合的语法与获取数据库时相同:

<?php
$connection 
= new MongoClient();
$db $connection->baz;

// select a collection:
$collection $db->foobar;

// or, directly selecting a database and collection:
$collection $connection->baz->foobar;
?>

一个集合相当于一张表。(如果你对关系型数据库比较熟悉)

参见

MongoCollection 类的文档中有对集合对象的详细说明。

add a note add a note

User Contributed Notes 1 note

up
0
jerome at chaman dot ca
9 years ago
If your collection uses dot notation, get it with MongoDB::selectCollection :

$colors = $db->selectCollection('my.colors');
To Top