示例#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() . ')');
             }
         }
     }
 }