mongo_close
mongo_find_one
Mongo Функции
PHP Manual

# mongo_connect

(PECL mongo >= 0.8.0)

mongo_connect — Connects to a database

### Описание

resource mongo_connect ( string `$host` , bool `$auto_reconnect` )

Creates a new database connection object.

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

`host`

  Address of the database to which to connect.

`auto_reconnect`

  If the driver should attempt to reconnect if the database connection is lost.

If able to connect, the connection resource is returned. Otherwise, false.

### Errors/Exceptions

If the server name is invalid (null or the empty string). If the driver is unable to connect to the host.

### Примеры

Пример #1 mongo_connect() example

To connect to a Mongo database running locally on the default port:

`<?php
$connection = mongo_connect("localhost", true);
// or, equivalently
$connection = mongo_connect("localhost:27017", true);
?>`

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

- mongo_close() - Closes a connection to the database

mongo_close
mongo_find_one
Mongo Функции
PHP Manual