Войти через VK Войти через FB Войти через Google Войти через Яндекс
Поиск по сайту
(PECL mongo >=0.9.0)
Mongo::__construct — Creates a new database connection object
ОписаниеMongo::__construct ([ string $server = "mongodb://localhost:27017" [, array $options = array("connect" => TRUE) ]] )
server should have the form:
The connection string always starts with mongodb://, to indicate it is a connection string in this form.
If username and password are specified, the constructor will attempt to authenticate the connection with the database before returning. Username and password are optional and must be followed by an @, if specified.
At least one host must be given (port optional, always defaulting to 27017) and as many hosts as desired may be connected to. Host names are comma-separated and the constructor will return successfully if it connected to at least one host. If it could not connect to any of the hosts, it will throw a MongoConnectionException.
Finally, if you specified a username and password, you may specify a database to authenticate with. If db is not specified, "admin" will be used.
The server name.
An array of options for the connection. Currently available options include:
If the constructor should connect before returning. Default is TRUE.
For how long the driver should try to connect to the database (in milliseconds).
The name of the replica set to connect to. If this is given, the master will be determined by using the ismaster database command on the seeds, so the driver may end up connecting to a server that was not even listed. See the replica set example below for details.
The username can be specified here, instead of including it in the host list. This is especially useful if a username has a ":" in it. This overrides a username set in the host list.
The password can be specified here, instead of including it in the host list. This is especially useful if a password has a "@" in it. This overrides a password set in the host list.
The database to authenticate against can be specified here, instead of including it in the host list. This overrides a database given in the host list.
Returns a new database connection object.
Throws MongoConnectionException if it tries and fails to connect to the database for all hostnames given. It will also throw a MongoConnnectionException if an invalid username or password is given. See MongoConnectionException documentation for common exceptions and their causes.
Описание на ru2.php.net
Описание на php.ru