Closes this database connection

Mongo
Mongo::connect
Mongo
PHP Manual

# Mongo::close

(PECL mongo >=0.9.0)

Mongo::close — Closes this database connection

### Description

public boolean Mongo::close ( void )

This method does not need to be called, except in unusual circumstances. The driver will cleanly close the database connection when the Mongo object goes out of scope.

If you are using a service where objects do not go out of scope between requests, you may wish to call close() at the end of your program to keep old connections from hanging around. However, it is probably more efficient to take advantage of this fact and simply use a persistent connection, which will automatically create a connection if needed and use it for as many requests as the application server allows it to exist.

You may also wish to call close() if you are unsure of the state of a connection and wish to guarantee a new connection will happen. For example:

`<?php
$mongo = new Mongo();
/* do stuff where the db connection may be lost */
/* if $mongo is already connected, does nothing */
$mongo->connect();
?>`

vs.

`<?php
$mongo = new Mongo();
/* do stuff where the db connection may be lost */
/* guarantee a reconnection to the db server */
$mongo->close()
$mongo->connect();
?>`

### Parameters

This function has no parameters.

### Return Values

Returns if the connection was successfully closed.

Mongo
Mongo::connect
Mongo
PHP Manual