Предопределенные константы
Mongo Функции
Mongo
PHP Manual

# Примеры

This example shows how to connect, insert objects, query for objects, iterate through query results, and disconnect from a Mongo database.

Пример #1 Mongo Example

`<?php
include "mongo.php";
// connect
$m = new Mongo();
// select a database
$db = $m->selectDatabase("comedy");
$collection = $db->selectCollection("cartoons");
// add an element
$obj = array( "title" => "Calvin and Hobbes", "author" => "Bill Watterson" );
$collection->insert($obj);
// add another element, with a different "shape"
$obj = array( "title" => "XKCD", "online" => true );
$collection->insert($obj);
// find everything in the collection
$cursor = $collection->find();
// iterate through the results
while( $cursor->hasNext() ) {
$c = $cursor->next();
echo $c["title"] . "\n";
}
// disconnect
$m->close();
?>`

Результатом выполнения данного примера будет что-то подобное:

    Calvin and Hobbes
    XKCD

Предопределенные константы
Mongo Функции
Mongo
PHP Manual