public method



  • array $config

    Configuration options required to connect to the database, including:

    • 'host' string|array: A string in the form of '<host>', '<host>:<port>' or ':<port>' indicating the host and/or port to connect to. When one or both are not provided uses general server defaults (if possible retrieved from the client implementation). Use the array format for multiple hosts: array('', '')
    • 'database' string: The name of the database to connect to. Defaults to null.
    • 'timeout' integer: The number of milliseconds a connection attempt will wait before timing out and throwing an exception. Defaults to 100.
    • 'schema' \Closure: A closure or anonymous function which returns the schema information for a model class. See the $_schema property for more information.
    • 'gridPrefix' string: The default prefix for MongoDB's chunks and files collections. Defaults to 'fs'.
    • 'replicaSet' string: See the documentation for Mongo::__construct(). Defaults to false.
    • 'readPreference' mixed: May either be a single value such as Mongo::RP_NEAREST, or an array containing a read preference and a tag set such as: (Mongo::RP_SECONDARY_PREFERRED, ['dc' => 'east] See the documentation for Mongo::setReadPreference(). Defaults to null. Typically, these parameters are set in Connections::add(), when adding the adapter to the list of active connections.

    Disables auto-connect, which is by default enabled in Source. Instead before each query execution the connection is checked and if needed (re-)established.




	public function __construct(array $config = []) {
		if (class_exists($server = $this->_classes['server'], false)) {
			$defaultHost = $server::DEFAULT_HOST . ':' . $server::DEFAULT_PORT;
		} else {
			$defaultHost = static::DEFAULT_HOST . ':' . static::DEFAULT_PORT;
		$defaults = [
			'host' => $defaultHost,
			'login'      => null,
			'password'   => null,
			'database'   => null,
			'timeout'    => 100,
			'replicaSet' => false,
			'schema'     => null,
			'gridPrefix' => 'fs',
			'w'          => 1,
			'wTimeoutMS' => 10000,
			'readPreference' => null,
			'autoConnect' => false,
			'dsn' => null
		parent::__construct($config + $defaults);