public function __construct(IDataSourceDriver &$driver) { $this->_driver =& $driver; $matches = array(); preg_match('~([a-z0-9_-]+):([a-z0-9_-]+)@([a-z0-9_-]+)\\.([a-z0-9_-]+)~i', $driver->getDomain(), $matches); if (5 != count($matches)) { throw new Exception('Cannot parse driver\'s domain for dbms context'); } else { $this->_dbUsername = $matches[1]; $this->_dbPasswd = $matches[2]; $this->_dbHost = $matches[3]; $this->_dbName = $matches[4]; } }
/** * @brief Retourne une instance connecté au dbms correspondant au driver * @param $driver IDataSourceDriver driver de connexion * @return DbmsDataSource */ public static function &getInstance(IDataSourceDriver &$driver) { if (is_null(self::$_instances)) { self::$_instances = array(); } $instance_key = $driver->getDomain(); if (!array_key_exists($instance_key, self::$_instances)) { self::$_instances[$instance_key] =& self::createNew($driver); } self::$_instances[$instance_key]->connect(); return self::$_instances[$instance_key]; }