Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 21018 программистов и 1218 роботов. Сейчас ищут 640 программистов ...
Приступая к работе

MongoDB\Driver\Manager::__construct - Create new MongoDB Manager

Вернуться к: MongoDB\Driver\Manager

MongoDB\Driver\Manager::__construct

(mongodb >=1.0.0)

MongoDB\Driver\Manager::__constructCreate new MongoDB Manager

Описание

final public MongoDB\Driver\Manager::__construct ( string $uri [, array $options [, array $driverOptions ]] )

Constructs a new MongoDB\Driver\Manager object with the specified options.

Список параметров

uri

A » mongodb:// connection URI:

mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]

options

» Connection string options.

Замечание:

Specifying options via the options argument will overwrite any options with the same name in the uri argument.

driverOptions

Any driver-specific options not included in MongoDB connection string specification.

Ошибки

Примеры

Пример #1 MongoDB\Driver\Manager::__construct() basic examples

Connecting to standalone MongoDB node:

<?php

$manager 
= new MongoDB\Driver\Manager("mongodb://localhost:27017");

?>

Connecting to a replica set:

<?php

$manager 
= new MongoDB\Driver\Manager("mongodb://rs1.example.com,rs2.example.com/?replicaSet=myReplicaSet");

?>

Connecting to a sharded cluster (i.e. one or more mongos instances):

<?php

$manager 
= new MongoDB\Driver\Manager("mongodb://mongos1.example.com,mongos2.example.com/");

?>

Connecting to MongoDB with authentication credentials for a particular user and database:

<?php

$manager 
= new MongoDB\Driver\Manager("mongodb://myusername:mypassword@localhost:27017/mydatabase");

?>

Смотрите также



Вернуться к: MongoDB\Driver\Manager

© 2024 «PHP.RU — Сообщество PHP-Программистов»
Главная | Форум | Реклама на сайте | Контакты VIP Сувениры
Разработка компании ODware