public method



  • array $config

    Configuration options required to connect to the database, including:

    • 'database' string: The name of the database to connect to. Defaults to null.
    • 'host' string: The IP or machine name where Mongo is running, followed by a colon, and the port number. Defaults to 'localhost:27017'.
    • 'persistent' mixed: Determines a persistent connection to attach to. See the $options parameter of Mongo::__construct() for more information. Defaults to false, meaning no persistent connection is made.
    • '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: array(Mongo::RP_SECONDARY_PREFERRED, array('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.




	public function __construct(array $config = array()) {
		$host = 'localhost:27017';

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