Рекурсивный акроним словосочетания «PHP: Hypertext Preprocessor»
Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 16267 программистов и 1781 робот. Сейчас ищут 1942 программиста ...
Getting a Database
Вернуться к: Tutorial
To select a database, use:
<?php
$connection = new MongoClient();
$db = $connection->dbname;
?>
The database does not need to be created in advance, you can create new databases by selecting them.
Be careful of typos! You can inadvertently create a new database, which can cause confusing errors (here name is misspelled as anme in the second selection:
<?php
$connection = new MongoClient();
$db = $connection->mybiglongdbname;
// do some stuff
$db = $connection->mybiglongdbanme;
// now connected to a different database!
?>
See Also
The API documentation on the MongoDB class contains more information about database objects.
Вернуться к: Tutorial