class ReadPreference (View source)

deprecated 1.3 No longer required; will be removed for 2.0

Utility class for converting read preferences.

This is necessary for versions of the driver <=1.3.2, where values returned by getReadPreference() are not consistent with those expected by setReadPreference(). See: https://jira.mongodb.org/browse/PHP-638.

Methods

static string
convertNumericType(integer $type)

Converts a numeric type returned by getReadPreference() methods to the constant accepted by setReadPreference() methods.

static array
convertReadPreference(array $readPref)

Converts return values from getReadPreference() methods to the format accepted by setReadPreference() methods.

static array
convertTagSets(array $tagSets)

Converts tag sets returned by getReadPreference() methods to the format accepted by setReadPreference() methods.

Details

static string convertNumericType(integer $type)

Converts a numeric type returned by getReadPreference() methods to the constant accepted by setReadPreference() methods.

Parameters

integer $type

Return Value

string

static array convertReadPreference(array $readPref)

Converts return values from getReadPreference() methods to the format accepted by setReadPreference() methods.

This is necessary for MongoClient, MongoDB, and MongoCollection classes in driver versions between 1.3.0 and 1.3.3.

Parameters

array $readPref

Return Value

array

static array convertTagSets(array $tagSets)

Converts tag sets returned by getReadPreference() methods to the format accepted by setReadPreference() methods.

Example input:

[['dc:east', 'use:reporting'], ['dc:west'], []]

Example output:

[['dc' => 'east', 'use' => 'reporting'], ['dc' => 'west'], []]

Parameters

array $tagSets

Return Value

array