MongoClient::getReadPreference

(PECL mongo >=1.3.0)

MongoClient::getReadPreference锟斤拷取锟斤拷锟斤拷锟接的讹拷取锟斤拷选锟斤拷

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.

说锟斤拷

public MongoClient::getReadPreference ( void ) : array

锟斤拷锟斤拷

锟剿猴拷锟斤拷没锟叫诧拷锟斤拷锟斤拷

锟斤拷锟斤拷值

This function returns an array describing the read preference. The array contains the values type for the string read preference mode (corresponding to the MongoClient constants), and tagsets containing a list of all tag set criteria. If no tag sets were specified, tagsets will not be present in the array.

锟斤拷锟斤拷锟斤拷志

锟芥本 说锟斤拷
1.3.3 锟斤拷锟截碉拷值锟睫革拷为锟斤拷锟斤拷 MongoClient::setReadPreference()锟斤拷 type 锟斤拷值锟斤拷锟斤拷锟斤拷某锟斤拷址锟斤拷锟斤拷锟缴撅拷锟斤拷锟� type_string锟斤拷锟斤拷锟斤拷 tagsets 锟斤拷锟斤拷锟皆硷拷值锟斤拷示锟侥憋拷签锟斤拷锟斤拷锟斤拷冒锟脚分革拷锟斤拷锟街凤拷锟斤拷锟斤拷

锟斤拷锟斤拷

Example #1 MongoClient::getReadPreference() 锟斤拷锟斤拷值锟斤拷锟斤拷

<?php

$m 
= new MongoClient();
$m->setReadPreference(MongoClient::RP_SECONDARY, array(
    array(
'dc' => 'east''use' => 'reporting'),
    array(
'dc' => 'west'),
    array(),
));
var_dump($m->getReadPreference());
?>

锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�

array(2) {
  ["type"]=>
  string(9) "secondary"
  ["tagsets"]=>
  array(3) {
    [0]=>
    array(2) {
      ["dc"]=>
      string(4) "east"
      ["use"]=>
      string(9) "reporting"
    }
    [1]=>
    array(1) {
      ["dc"]=>
      string(7) "west"
    }
    [2]=>
    array(0) {
    }
  }
}

锟轿硷拷