lithium\data\source\MongoDb::__construct PHP Method

__construct() public method

Constructor.
See also: lithium\data\Connections::add()
See also: lithium\data\source\MongoDb::$_schema
public __construct ( array $config = [] ) : void
$config array 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()`](http://php.net/mongo.construct.php) 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.
return void
    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);
    }

Usage Example

 public function __construct(array $config = array())
 {
     $this->_classes['entity'] = 'li3_mongo_embedded\\extensions\\data\\entity\\Document';
     $this->_classes['schema'] = 'li3_mongo_embedded\\extensions\\data\\source\\mongo_db\\Schema';
     $this->_classes['set'] = 'li3_mongo_embedded\\extensions\\data\\collection\\DocumentSet';
     parent::__construct($config);
     $this->_readEmbeddedFilter();
 }
All Usage Examples Of lithium\data\source\MongoDb::__construct