Mongo::close

(PECL mongo >=0.9.0)

Mongo::closeCloses this connection

Description

public bool Mongo::close ( void )

The Mongo::close() method forcefully closes a connection to the database, even if persistent connections are being used. You do under normal circumstance never have to do this.

If you are connected to a replica set, close() will only close the connection to the primary.

Parameters

This function has no parameters.

Return Values

Returns if the connection was successfully closed.

Changelog

Version Description
1.2.0

Before version 1.2.0 the driver would not use persistent connections by default, and all connections would be closed as soon as a MongoDB connection went out if scope. Since version 1.2.0 this is no longer the case and it is a bad idea to call close as you might end up overloading the server with connections under high load.