getReadPreference() 공개 메소드

Get the read preference for this connection
public getReadPreference ( ) : array
리턴 array -
예제 #1
0
 /**
  * Creates a new database
  *
  * This method is not meant to be called directly. The preferred way to create an instance of MongoDB is through {@see Mongo::__get()} or {@see Mongo::selectDB()}.
  * @link http://www.php.net/manual/en/mongodb.construct.php
  * @param MongoClient $conn Database connection.
  * @param string $name Database name.
  * @throws Exception
  * @return MongoDB Returns the database.
  */
 public function __construct(MongoClient $conn, $name)
 {
     $this->connection = $conn;
     $this->name = $name;
     $this->setReadPreferenceFromArray($conn->getReadPreference());
     $this->setWriteConcernFromArray($conn->getWriteConcern());
     $this->createDatabaseObject();
 }
예제 #2
0
 /**
  * Create a new cursor
  *
  * @param MongoClient $client     - Database connection.
  * @param string      $ns         - Full name of database and collection.
  * @param array       $query      - Database query.
  * @param array       $fields     - Fields to return.
  */
 public function __construct(MongoClient $client, $ns, array $query = [], array $fields = [])
 {
     $this->client = $client;
     $this->readPreference = $client->getReadPreference();
     $this->fcn = $ns;
     $this->fields = $fields;
     $this->query['$query'] = $query;
     $this->queryTimeout = self::$timeout;
 }
예제 #3
0
 /**
  * Wrapper method for MongoClient::getReadPreference().
  *
  * For driver versions between 1.3.0 and 1.3.3, the return value will be
  * converted for consistency with {@link Connection::setReadPreference()}.
  *
  * @see http://php.net/manual/en/mongoclient.getreadpreference.php
  * @return array
  */
 public function getReadPreference()
 {
     $this->initialize();
     return $this->mongoClient->getReadPreference();
 }
예제 #4
0
 /**
  * Creates a new database
  *
  * @param MongoClient $client - Database connection.
  * @param string $name - Database name.
  */
 public function __construct(MongoClient $client, $name)
 {
     $this->name = $name;
     $this->client = $client;
     $this->readPreference = $client->getReadPreference();
 }