No databases or collections have to do be explicitly created:
<?php
$m = new MongoClient();
$database = $m->selectDB( 'demo' );
$collection = $database->selectCollection( 'testCollection' );
// or
$collection = $m->selectCollection( 'demo', 'testCollection' );
?>
Different connection strings:
- • new MongoClient("mongodb://localhost");
- • new MongoClient("mongodb://localhost:29000");
- • new MongoClient("mongodb://mongo.example.com");