Example #1
0
 /**
  * @param Identifier $Identifier
  *
  * @throws \Exception
  */
 function __construct(Identifier $Identifier)
 {
     $this->Identifier = $Identifier;
     $Register = new Register();
     if (!$Register->hasConnection($this->Identifier)) {
         $Configuration = parse_ini_file(__DIR__ . '/Configuration.ini', true);
         if (isset($Configuration[$this->Identifier->getConfiguration(true)])) {
             $this->Configuration = $Configuration[$this->Identifier->getConfiguration(true)];
             $Driver = '\\SPHERE\\System\\Database\\Type\\' . $this->Configuration['Driver'];
             $Register->addConnection($this->Identifier, new Connection($this->Identifier, new $Driver(), $this->Configuration['Username'], $this->Configuration['Password'], empty($this->Configuration['Database']) ? str_replace(':', '', $this->Identifier->getConfiguration(false)) : $this->Configuration['Database'], $this->Configuration['Host'], empty($this->Configuration['Port']) ? null : $this->Configuration['Port'], $this->Timeout));
         } else {
             if (isset($Configuration[$this->Identifier->getConfiguration(false)])) {
                 $this->Configuration = $Configuration[$this->Identifier->getConfiguration(false)];
                 $Driver = '\\SPHERE\\System\\Database\\Type\\' . $this->Configuration['Driver'];
                 $Register->addConnection($this->Identifier, new Connection($this->Identifier, new $Driver(), $this->Configuration['Username'], $this->Configuration['Password'], empty($this->Configuration['Database']) ? str_replace(':', '', $this->Identifier->getConfiguration(false)) : $this->Configuration['Database'], $this->Configuration['Host'], empty($this->Configuration['Port']) ? null : $this->Configuration['Port'], $this->Timeout));
             } else {
                 throw new \Exception(__CLASS__ . ' > Missing Configuration: (' . $this->Identifier->getConfiguration() . ')');
             }
         }
     }
 }
 /**
  * @param Identifier     $Identifier
  * @param ITypeInterface $Type
  * @param string         $Username
  * @param string         $Password
  * @param string         $Database
  * @param string         $Host
  * @param null|int       $Port
  *
  * @param int            $Timeout
  *
  * @throws \Exception
  */
 public final function __construct(Identifier $Identifier, ITypeInterface $Type, $Username, $Password, $Database, $Host, $Port = null, $Timeout = 5)
 {
     $Consumer = $Identifier->getConsumer();
     $this->setConnection($Username, $Password, $Database . (empty($Consumer) ? '' : '_' . $Consumer), $Type->getIdentifier(), $Host, $Port, $Timeout);
 }