php8.5
Home/ Manual/ driver / server/ MongoDB\Driver\Server::executeQuery

MongoDB\Driver\Server::executeQuery

PHP function Edit on GitHub ✎

(mongodb >=1.0.0)

Execute a database query on this server

Description

MongoDB\Driver\Server::executeQuery(string $namespace, MongoDB\Driver\Query $query, array|null $options = null): MongoDB\Driver\Cursor

Executes the query on this server.

Default values for the "readPreference" option and Query's "readConcern" option will be inferred from an active transaction (indicated by the "session" option), followed by the connection URI.

Readpreference

Parameters

options
OptionTypeDescription

Return Values Cursor

Errors/Exceptions

  • Throws MongoDB\Driver\Exception\RuntimeException on other errors (e.g. invalid query operators).

Changelog

VersionDescription
PECL mongodb 2.0.0The options parameter no longer accepts a MongoDB\Driver\ReadPreference instance.
PECL mongodb 1.21.0Passing a MongoDB\Driver\ReadPreference object as options is deprecated and will be removed in 2.0.
PECL mongodb 1.4.0The third parameter is now an options array. For backwards compatibility, this parameter will still accept a MongoDB\Driver\ReadPreference object.

See Also

Source: reference/mongodb/mongodb/driver/server/executequery.xml · from the official PHP manual (php/doc-en)