final class Server (View source)

Constants

TYPE_UNKNOWN

TYPE_STANDALONE

TYPE_MONGOS

TYPE_POSSIBLE_PRIMARY

TYPE_RS_PRIMARY

TYPE_RS_SECONDARY

TYPE_RS_ARBITER

TYPE_RS_OTHER

TYPE_RS_GHOST

TYPE_LOAD_BALANCER Since: 1.11.0

Methods

__wakeup()

No description

executeBulkWrite(string $namespace, BulkWrite $bulkWrite, WriteConcern|null $options = null)

Execute one or more write operations on this server

executeCommand(string $db, Command $command, ReadPreference|null $options = null)

Execute a database command on this server

executeReadCommand(string $db, Command $command, array|null $options = null)

Execute a database command that reads on this server

executeReadWriteCommand(string $db, Command $command, array|null $options = null)

Execute a database command that reads and writes on this server

executeWriteCommand(string $db, Command $command, array|null $options = null)

Execute a database command that writes on this server

executeQuery(string $namespace, Query $query, ReadPreference|null $options = null)

Execute a database query on this server

string
getHost()

Returns the hostname of this server

array
getInfo()

Returns an array of information about this server

int
getLatency()

Returns the latency of this server

int
getPort()

Returns the port on which this server is listening

array
getTags()

Returns an array of tags describing this server in a replica set

int
getType()

Returns an integer denoting the type of this server

bool
isArbiter()

Checks if this server is an arbiter member of a replica set

bool
isHidden()

Checks if this server is a hidden member of a replica set

bool
isPassive()

Checks if this server is a passive member of a replica set

bool
isPrimary()

Checks if this server is a primary member of a replica set

bool
isSecondary()

Checks if this server is a secondary member of a replica set

Details

final __wakeup()

No description

final WriteResult executeBulkWrite(string $namespace, BulkWrite $bulkWrite, WriteConcern|null $options = null)

Since: 1.0.0

Execute one or more write operations on this server

Parameters

string $namespace

A fully qualified namespace (e.g. "databaseName.collectionName").

BulkWrite $bulkWrite

The MongoDB\Driver\BulkWrite to execute.

WriteConcern|null $options

Return Value

WriteResult

Exceptions

BulkWriteException
InvalidArgumentException
ConnectionException
AuthenticationException
RuntimeException

final Cursor executeCommand(string $db, Command $command, ReadPreference|null $options = null)

Since: 1.0.0

Execute a database command on this server

Parameters

string $db

The name of the database on which to execute the command.

Command $command

The MongoDB\Driver\Command to execute.

ReadPreference|null $options

Optionally, a MongoDB\Driver\ReadPreference to select the server for this operation. If none is given, the read preference from the MongoDB Connection URI will be used.

Return Value

Cursor

Exceptions

InvalidArgumentException
ConnectionException
AuthenticationException
RuntimeException

final Cursor executeReadCommand(string $db, Command $command, array|null $options = null)

Since: 1.4.0

Execute a database command that reads on this server

Parameters

string $db
Command $command
array|null $options

Return Value

Cursor

Exceptions

InvalidArgumentException
ConnectionException
AuthenticationException
RuntimeException

final Cursor executeReadWriteCommand(string $db, Command $command, array|null $options = null)

Since: 1.4.0

Execute a database command that reads and writes on this server

Parameters

string $db
Command $command
array|null $options

Return Value

Cursor

Exceptions

InvalidArgumentException
ConnectionException
AuthenticationException
RuntimeException

final Cursor executeWriteCommand(string $db, Command $command, array|null $options = null)

Since: 1.4.0

Execute a database command that writes on this server

Parameters

string $db
Command $command
array|null $options

Return Value

Cursor

Exceptions

InvalidArgumentException
ConnectionException
AuthenticationException
RuntimeException

final Cursor executeQuery(string $namespace, Query $query, ReadPreference|null $options = null)

Execute a database query on this server

Parameters

string $namespace

A fully qualified namespace (e.g. "databaseName.collectionName").

Query $query

The MongoDB\Driver\Query to execute.

ReadPreference|null $options

Return Value

Cursor

Exceptions

InvalidArgumentException
ConnectionException
AuthenticationException
RuntimeException

final string getHost()

Returns the hostname of this server

Return Value

string

Exceptions

InvalidArgumentException

final array getInfo()

Returns an array of information about this server

Return Value

array

Exceptions

InvalidArgumentException

final int getLatency()

Returns the latency of this server

Return Value

int

Exceptions

InvalidArgumentException

final int getPort()

Returns the port on which this server is listening

Return Value

int

Exceptions

InvalidArgumentException

final ServerDescription getServerDescription()

Since: 1.13.0

Return Value

ServerDescription

final array getTags()

Returns an array of tags describing this server in a replica set

Return Value

array

An array of tags used to describe this server in a replica set. The array will contain zero or more string key and value pairs.

Exceptions

InvalidArgumentException

final int getType()

Returns an integer denoting the type of this server

Return Value

int

denoting the type of this server

Exceptions

InvalidArgumentException

final bool isArbiter()

Checks if this server is an arbiter member of a replica set

Return Value

bool

Exceptions

InvalidArgumentException

final bool isHidden()

Checks if this server is a hidden member of a replica set

Return Value

bool

Exceptions

InvalidArgumentException

final bool isPassive()

Checks if this server is a passive member of a replica set

Return Value

bool

Exceptions

InvalidArgumentException

final bool isPrimary()

Checks if this server is a primary member of a replica set

Return Value

bool

Exceptions

InvalidArgumentException

final bool isSecondary()

Checks if this server is a secondary member of a replica set

Return Value

bool

Exceptions

InvalidArgumentException