LMongo\Connection::connect PHP Method

connect() public method

Establish a database connection.
public connect ( array $config ) : LMongo\Connection
$config array
return LMongo\Connection
    public function connect(array $config)
    {
        if (!is_null($this->connection)) {
            return;
        }
        $this->config = $config;
        $options = array_get($this->config, 'options', array());
        $this->connection = new \MongoClient($this->getDsn($config), $options);
        //Select database
        $this->db = $this->connection->{$config['database']};
        return $this;
    }

Usage Example

Beispiel #1
0
 /**
  * Make the database connection instance.
  *
  * @param  string  $name
  * @return Illuminate\Database\Connection
  */
 protected function makeConnection($name)
 {
     $config = $this->getConfig($name);
     if (isset($this->extensions[$name])) {
         return call_user_func($this->extensions[$name], $config);
     }
     $connection = new Connection();
     return $connection->connect($config);
 }