
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
PHP MongoDB context options
Introduction
PHP can interact with MongoDB database through database extensions. For older versions of PHP, mongo driver can be installed from PECL. This has now been replaced by mongodb driver. Both drivers can be installed using precompiled binaries for Linux/Windows/MacOS operating systems. Alternately, manual installation can be done from source tarball available on github. In either case, mongo or mongodb extension should be enabled in php.ini settings.
The PHP MongoDB extension provides Stream Context Support using the mongodb context. Relevent context options are as follows
Options
log_cmd_insert ( array $server , array $document , array $writeOptions , array $protocolOptions )
This is a callable function, used by the log_cmd_insert context option, when inserting a document
log_cmd_delete ( array $server , array $writeOptions , array $deleteOptions , array $protocolOptions )
This is a callback function, used by the log_cmd_delete context option, when deleteing a document
log_cmd_update ( array $server , array $writeOptions , array $updateOptions , array $protocolOptions )
This function is used by the log_cmd_update context option, when updateing a document
log_write_batch ( array $server , array $writeOptions , array $batch , array $protocolOptions )
This function is used by the log_write_batch context option, when executing a batch operation.
log_reply ( array $server , array $messageHeaders , array $operationHeaders )
This callback function is used When Reading the MongoDB reply
log_getmore ( array $server , array $info )
when executing a GET_MORE operation, this callable function is used by the log_getmore context option
log_killcursor ( array $server , array $info )
Callback When Executing KILLCURSOR operations
$server array contains basic information of following parameters
hash− server hash, example: localhost:27017;-;X;56052
type − Node type (primary/secondary/mongos/arbiter) − 2
max_bson_size − The maximum BSON Size over the wire this node accepts − 16777216
max_message_size − The maximum Message Size over the wire this node accepts − 48000000
request_id − The request identifier for this message − 42
- Related Articles
- PHP FTP context options
- PHP HTTP context options
- PHP Phar context options
- PHP Socket context options
- PHP SSL context options
- PHP Zip context options
- CURL context options in PHP
- PHP Context Parameters
- Python Context Variables
- Perl Variable Context
- Python Context Manager Types
- Context api in React.js
- Context API in ReactJS
- What is Context on Android?
- Subroutine Call Context in Perl
