Documentation

EstimatedDocumentCount
in package
implements Explainable

FinalYes

Operation for obtaining an estimated count of documents in a collection

Tags
see
Collection::estimatedDocumentCount()
see
https://mongodb.com/docs/manual/reference/command/count/

Table of Contents

Interfaces

Explainable

Properties

$collectionName  : string
$databaseName  : string
$options  : array<string|int, mixed>

Methods

__construct()  : mixed
Constructs a command to get the estimated number of documents in a collection.
execute()  : int
Execute the operation.
getCommandDocument()  : array<string|int, mixed>
Returns the command document for this operation.
createCount()  : Count

Properties

Methods

__construct()

Constructs a command to get the estimated number of documents in a collection.

public __construct(string $databaseName, string $collectionName[, array<string|int, mixed> $options = [] ]) : mixed

Supported options:

  • comment (mixed): BSON value to attach as a comment to this command.

    This is not supported for servers versions < 4.4.

  • maxTimeMS (integer): The maximum amount of time to allow the query to run.

  • readConcern (MongoDB\Driver\ReadConcern): Read concern.

  • readPreference (MongoDB\Driver\ReadPreference): Read preference.

  • session (MongoDB\Driver\Session): Client session.

Parameters
$databaseName : string

Database name

$collectionName : string

Collection name

$options : array<string|int, mixed> = []

Command options

Tags
throws
InvalidArgumentException

for parameter/option parsing errors

execute()

Execute the operation.

public execute(Server $server) : int
Parameters
$server : Server
Tags
throws
UnexpectedValueException

if the command response was malformed

throws
UnsupportedException

if collation or read concern is used and unsupported

throws
RuntimeException

for other driver errors (e.g. connection errors)

Return values
int

getCommandDocument()

Returns the command document for this operation.

public getCommandDocument() : array<string|int, mixed>
Tags
see
Explainable::getCommandDocument()
Return values
array<string|int, mixed>

        
On this page

Search results