Keine Cache-Version


Caching deaktiviert Standardeinstellung für diese Seite:aktiviert (code LNG204)
Wenn die Anzeige zu langsam ist, können Sie den Benutzermodus deaktivieren, um die zwischengespeicherte Version anzuzeigen.

Rechercher une fonction PHP

MongoClient::close

(PECL mongo >=1.3.0)

MongoClient::closeCloses this connection

Beschreibung

public MongoClient::close ([ boolean|string $connection ] ) : bool

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

Erste Seite von PHP-Handbuch Inhaltsverzeichnis Haut

Parameter-Liste

connection

If connection is not given, or FALSE then connection that would be selected for writes would be closed. In a single-node configuration, that is then the whole connection, but if you are connected to a replica set, close() will only close the connection to the primary server.

If connection is TRUE then all connections as known by the connection manager will be closed. This can include connections that are not referenced in the connection string used to create the object that you are calling close on.

If connection is a string argument, then it will only close the connection identified by this hash. Hashes are identifiers for a connection and can be obtained by calling MongoClient::getConnections().

Erste Seite von PHP-Handbuch Inhaltsverzeichnis Haut

Rückgabewerte

Returns if the connection was successfully closed.

Erste Seite von PHP-Handbuch Inhaltsverzeichnis Haut

Beispiele

Beispiel #1 MongoClient::close() example

This example demonstrates how to selectively close all connections for secondaries only.

<?php
// Connect to a replicaset
$a = new MongoClient("mongodb://whisky:13000/?replicaset=seta");

$connections $a->getConnections();

foreach ( 
$connections as $con )
{
    
// Loop over all the connections, and when the type is "SECONDARY"
    // we close the connection
    
if ( $con['connection']['connection_type_desc'] == "SECONDARY" )
    {
        echo 
"Closing '{$con['hash']}': ";
        
$closed $a->close$con['hash'] );
        echo 
$closed "ok" "failed""\n";
    }
}
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

Closing 'whisky:13001;X;4948': ok

Erste Seite von PHP-Handbuch Inhaltsverzeichnis Haut

Changelog

Version Beschreibung
1.3.0

The connection parameter to this function was added in 1.3.0. Before that, only the write connection would be closed by this method.

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.

Erste Seite von PHP-Handbuch Inhaltsverzeichnis Haut

Siehe auch

Finde eine PHP-Funktion

Deutsche Übersetzung

Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.

Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.

Vielen Dank im Voraus.

Dokument erstellt 30/01/2003, zuletzt geändert 26/10/2018
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/php-rf-mongoclient.close.html

Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.

Referenzen

  1. Zeigen Sie - html-Dokument Sprache des Dokuments:fr Manuel PHP : http://php.net

Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.

Inhaltsverzeichnis Haut