Getting A Collection
Getting a collection has the same syntax as getting a database:
<?php
$connection = new MongoClient();
$db = $connection->baz;
// select a collection:
$collection = $db->foobar;
// or, directly selecting a database and collection:
$collection = $connection->baz->foobar;
?>
A collection is analogous to a table (if you are familiar with relational databases).
See Also
The API documentation on the MongoCollection class contains more information about collection objects.
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Расширения для работы с базами данных
- Расширения для работы с базами данных отдельных производителей
- MongoDB
- Manual
- Making a Connection
- Getting a Database
- Getting A Collection
- Inserting a Document
- Finding Documents using MongoCollection::findOne
- Adding Multiple Documents
- Counting Documents in A Collection
- Using a Cursor to Get All of the Documents
- Setting Criteria for a Query
- Getting A Set of Documents With a Query
- Creating An Index
Коментарии
If your collection uses dot notation, get it with MongoDB::selectCollection :
$colors = $db->selectCollection('my.colors');