Duffer Derek
<?php namespace App\Repository\General;
use MongoClient;
/**
* Created by PhpStorm.
* User: jis
* Date: 18/3/15
* Time: 2:36 PM
*/
abstract class MongoConnection
{
// abstract protected function setMongoConnection();
protected $connection = null, $host, $port, $database;
private function setConnection()
{
$this->host = 'localhost';
$this->port = '27017';
$this->database = 'logmein';
$dsn = $this->getDsn();
$connection = new MongoClient($dsn, array(
"socketTimeoutMS" => 100000
));
$this->connection = $connection->{$this->database};
}
protected function getDsn()
{
$host = "{$this->host}:{$this->port}";
return "mongodb://" . $host . "/{$this->database}";
}
protected function getCollection($collection)
{
if (!$this->connection)
$this->setConnection();
return $this->connection->{$collection};
}
}
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists