mongo_find_one> <mongo_close
Last updated: Mon, 28 Dec 2009

mongo_connect

(PECL mongo >= 0.8.0)

mongo_connectConnects to a database

Descrição

resource mongo_connect ( string $server , string $username , string $password , bool $persistent , bool $paired , bool $lazy )

Creates a new database connection object.

Parâmetros

host

Address of the database to which to connect.

username

An identifier for the connection. Only necessary for persistent, authenticated connections, otherwise it can be set to "".

password

An identifier for the connection. Only necessary for persistent, authenticated connections, otherwise it can be set to "".

persistent

If the connection should be persistent.

paired

If the paired database servers are being used.

lazy

If persistent and lazy are set and no existing database connection is found, do not connect.

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

Erros

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

Exemplos

Exemplo #1 mongo_connect() example

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

<?php

$connection 
mongo_connect("localhost"""""falsefalsefalse);
// or, equivalently
$connection mongo_connect("localhost:27017"""""falsefalsefalse);

?>

Veja Também



User Contributed Notes
mongo_connect
There are no user contributed notes for this page.

mongo_find_one> <mongo_close
Last updated: Mon, 28 Dec 2009