Example #1
0
 /**
  * @param $connection_string
  *
  * @return Connection
  * @throws \Exception
  */
 public static function getInstance($connection_string)
 {
     if (!$connection_string) {
         throw new \Exception("Empty connection string");
     }
     if (empty(self::$cfg[$connection_string])) {
         throw new \Exception("Empty config {$connection_string}");
     }
     $info = static::parse_connection_url(self::$cfg[$connection_string]);
     if (empty(self::$connections[$connection_string])) {
         try {
             $connection = new self($info);
             if (isset($info->charset)) {
                 $connection->set_encoding($info->charset);
             }
         } catch (PDOException $e) {
             throw new \Exception($e);
         }
         self::$connections[$connection_string] = $connection;
     }
     return self::$connections[$connection_string];
 }