PHP Doku:: Closes this database connection - mongo.close.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzDatenbankerweiterungenAnbieterspezifische DatenbankerweiterungenMongoDB Native DriverCore ClassesThe Mongo classMongo::close

Ein Service von Reinhard Neidl - Webprogrammierung.

The Mongo class

<<The Mongo class

Mongo::connect>>

Mongo::close

(PECL mongo >=0.9.0)

Mongo::closeCloses this database connection

Beschreibung

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(); 

?>

Parameter-Liste

Diese Funktion hat keine Parameter.

Rückgabewerte

Returns if the connection was successfully closed.


Keine BenutzerBeiträge.
- Beiträge aktualisieren...



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)