Rechercher une fonction PHP

The MongoDB\Driver\Manager class

(mongodb >=1.0.0)

Introduction

The MongoDB\Driver\Manager is the main entry point to the extension. It is responsible for maintaining connections to MongoDB (be it standalone server, replica set, or sharded cluster).

No connection to MongoDB is made upon instantiating the Manager. This means the MongoDB\Driver\Manager can always be constructed, even though one or more MongoDB servers are down.

Any write or query can throw connection exceptions as connections are created lazily. A MongoDB server may also become unavailable during the life time of the script. It is therefore important that all actions on the Manager to be wrapped in try/catch statements.

Retour à la première page de Manuel PHP  Table des matières Haut

Synopsis de la classe

final MongoDB\Driver\Manager {
/* Méthodes */
final public __construct ([ string $uri = "mongodb://127.0.0.1/" [, array $uriOptions = array() [, array $driverOptions = array() ]]] )
final public executeBulkWrite ( string $namespace , MongoDB\Driver\BulkWrite $bulk [, array $options = array() ] ) : MongoDB\Driver\WriteResult
final public executeCommand ( string $db , MongoDB\Driver\Command $command [, array $options = array() ] ) : MongoDB\Driver\Cursor
final public executeQuery ( string $namespace , MongoDB\Driver\Query $query [, array $options = array() ] ) : MongoDB\Driver\Cursor
final public executeReadCommand ( string $db , MongoDB\Driver\Command $command [, array $options = array() ] ) : MongoDB\Driver\Cursor
final public executeReadWriteCommand ( string $db , MongoDB\Driver\Command $command [, array $options = array() ] ) : MongoDB\Driver\Cursor
final public executeWriteCommand ( string $db , MongoDB\Driver\Command $command [, array $options = array() ] ) : MongoDB\Driver\Cursor
final public getReadConcern ( void ) : MongoDB\Driver\ReadConcern
final public getReadPreference ( void ) : MongoDB\Driver\ReadPreference
final public getServers ( void ) : array
final public getWriteConcern ( void ) : MongoDB\Driver\WriteConcern
final public selectServer ( MongoDB\Driver\ReadPreference $readPreference ) : MongoDB\Driver\Server
final public startSession ([ array $options ] ) : MongoDB\Driver\Session
}

Retour à la première page de Manuel PHP  Table des matières Haut

Exemples

Exemple #1 MongoDB\Driver\Manager::__construct() basic example

var_dump()ing a MongoDB\Driver\Manager will print out various details about the manager that are otherwise not normally exposed. This can be useful to debug how the driver views your MongoDB setup, and which options are used.

<?php

$manager 
= new MongoDB\Driver\Manager("mongodb://localhost:27017");
var_dump($manager);

?>

L'exemple ci-dessus va afficher quelque chose de similaire à :

object(MongoDB\Driver\Manager)#1 (3) {
  ["request_id"]=>
  int(1714636915)
  ["uri"]=>
  string(25) "mongodb://localhost:27017"
  ["cluster"]=>
  array(13) {
    ["mode"]=>
    string(6) "direct"
    ["state"]=>
    string(4) "born"
    ["request_id"]=>
    int(0)
    ["sockettimeoutms"]=>
    int(300000)
    ["last_reconnect"]=>
    int(0)
    ["uri"]=>
    string(25) "mongodb://localhost:27017"
    ["requires_auth"]=>
    int(0)
    ["nodes"]=>
    array(...)
    ["max_bson_size"]=>
    int(16777216)
    ["max_msg_size"]=>
    int(50331648)
    ["sec_latency_ms"]=>
    int(15)
    ["peers"]=>
    array(0) {
    }
    ["replSet"]=>
    NULL
  }
}

Retour à la première page de Manuel PHP  Table des matières Haut

Sommaire

Rechercher une fonction PHP

Document créé le 30/01/2003, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/php-rf-class.mongodb-driver-manager.html

L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.

Références

  1. Consulter le document html Langue du document :fr Manuel PHP : http://php.net

Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.

Table des matières Haut