Рекурсивный акроним словосочетания «PHP: Hypertext Preprocessor»
Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 18494 программиста и 1739 роботов. Сейчас ищут 1273 программиста ...
Making a Connection
Вернуться к: Tutorial
To connect to the database server, use one of the following:
<?php
$connection = new MongoClient(); // connects to localhost:27017
$connection = new MongoClient( "mongodb://example.com" ); // connect to a remote host (default port: 27017)
$connection = new MongoClient( "mongodb://example.com:65432" ); // connect to a remote host at a given port
?>
You do not have to explicitly disconnect from the database. The driver uses persistent connections and will re-use already established connections.
See Also
The chapter on connecting covers different types of connections.
The API documentation on the MongoClient class and MongoClient::__construct() give a comprehensive look at all possible options with a number of examples.
Вернуться к: Tutorial