Example #1
0
 public function loadConfig($database, $type)
 {
     switch ($type) {
         case 'MASTER':
             return new \ArrayIterator(array($this->configs[$database][$type]));
         default:
             return new \ArrayIterator(\Frame\Helper\Util::ssort($this->configs[$database][$type]));
     }
 }
Example #2
0
 public function getConnection($type)
 {
     if (isset($this->conns[$type]) && !is_null($this->conns[$type])) {
         return $this->conns[$type];
     }
     $config = $this->loadConfig($this->database, $type);
     $host = $config['HOST'];
     $port = $config['PORT'];
     $user = $config['USER'];
     $pass = $config['PASS'];
     $db = $config['DB'];
     $this->conns[$type] = \Frame\Helper\Util::retry($this->connectRetry, function () use($host, $db, $user, $pass, $port) {
         return new \Frame\Connect\Database($host, $db, $user, $pass, $port);
     });
     return $this->conns[$type];
 }