MongoClient::setReadPreference

(PECL mongo >=1.3.0)

MongoClient::setReadPreferenceSet the read preference for this connection

This extension that defines this method is deprecated. Instead, the MongoDB extension should be used. There is no equivalent for this method in the new extension.

Opis

public MongoClient::setReadPreference ( string $read_preference [, array $tags ] ) : bool

Parametry

read_preference

Tryb preferencji odczytu: MongoClient::RP_PRIMARY, MongoClient::RP_PRIMARY_PREFERRED, MongoClient::RP_SECONDARY, MongoClient::RP_SECONDARY_PREFERRED, or MongoClient::RP_NEAREST.

tags

Tablica jednego lub więcej zbiorów tagów, gdzie każdy zbiór tagów jest sam w sobie tablicą kryteriów stosowanych do dopasowania tagów na elementach zbioru replik.

Zwracane wartości

Zwraca TRUE w przypadku powodzenia lub FALSE w przeciwnym przypadku.

Błędy/Wyjątki

Generuje błąd poziomu E_WARNING jeśli parametr jest nieprawidłowy, lub podano jeden lub więcej zbiorów tagów przy stosowaniu trybu preferencji odczytu MongoClient::RP_PRIMARY.

Przykłady

Przykład #1 MongoClient::setReadPreference() tag set array syntax example

<?php

$m 
= new MongoClient();

// Prefer the nearest server in the "east" data center also used for reporting,
// but fall back to a server in the "west" data center
$m->setReadPreference(MongoClient::RP_NEAREST, array(
    array(
'dc' => 'east''use' => 'reporting'),
    array(
'dc' => 'west'),
));
?>

Zobacz też:

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top