PHP Classes

File: vendor/mongodb/mongodb/docs/reference/method/MongoDBDatabase-withOptions.txt

Recommend this page to a friend!
  Classes of walid laggoune   MongoDB Queue PHP Query Execute   vendor/mongodb/mongodb/docs/reference/method/MongoDBDatabase-withOptions.txt   Download  
File: vendor/mongodb/mongodb/docs/reference/method/MongoDBDatabase-withOptions.txt
Role: Documentation
Content type: text/plain
Description: Documentation
Class: MongoDB Queue PHP Query Execute
Query and execute multiple queries using MongoDB
Author: By
Last change:
Date: 4 years ago
Size: 1,287 bytes
 

Contents

Class file image Download
================================ MongoDB\\Database::withOptions() ================================ .. default-domain:: mongodb .. contents:: On this page :local: :backlinks: none :depth: 1 :class: singlecol Definition ---------- .. phpmethod:: MongoDB\\Database::withOptions() Returns a clone of the Database object, but with different options. .. code-block:: php function withOptions(array $options = []): MongoDB\Database This method has the following parameters: .. include:: /includes/apiargs/MongoDBDatabase-method-withOptions-param.rst The ``$options`` parameter supports the following options: .. include:: /includes/apiargs/MongoDBDatabase-method-withOptions-option.rst Return Values ------------- A :phpclass:`MongoDB\\Database` object. Errors/Exceptions ----------------- .. include:: /includes/extracts/error-invalidargumentexception.rst Example ------- The following example clones an existing Database object with a new read preference: .. code-block:: php <?php $db = (new MongoDB\Client)->test; $newDb = $db->withOptions([ 'readPreference' => new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY), ]); See Also -------- - :phpmethod:`MongoDB\\Database::__construct()`