public static function getInstance($options = [])
	{
		// Sanitize the database connector options
		$options['driver']   = (isset($options['driver']))   ? preg_replace('/[^A-Z0-9_\.-]/i', '', $options['driver']) : 'mysql';
		$options['database'] = (isset($options['database'])) ? $options['database']                                     : null;
		$options['select']   = (isset($options['select']))   ? $options['select']                                       : true;

		// @TODO: Eventually remove this?
		if ($options['driver'] == 'pdo')
		{
			$options['driver'] = 'mysql';
		}

		// Get the options signature for the database connector
		$signature = md5(serialize($options));

		// If we already have a database connector instance for these options, then just use that
		if (!isset(self::$instances[$signature]))
		{
			// Derive the class name from the driver
			$class = __NAMESPACE__ . '\Driver\\' . ucfirst(strtolower($options['driver']));

			// If the class doesn't exist we have a problem
			if (!class_exists($class))
			{
				throw new RuntimeException('Database driver not available.', 500);
			}

			// Set the new connector to the global instances based on signature
			self::$instances[$signature] = new $class($options);
		}

		return self::$instances[$signature];
	}
public static function getInstance($options = [])
	{
		// Sanitize the database connector options
		$options['driver']   = (isset($options['driver']))   ? preg_replace('/[^A-Z0-9_\.-]/i', '', $options['driver']) : 'mysql';
		$options['database'] = (isset($options['database'])) ? $options['database']                                     : null;
		$options['select']   = (isset($options['select']))   ? $options['select']                                       : true;

		// @TODO: Eventually remove this?
		if ($options['driver'] == 'pdo')
		{
			$options['driver'] = 'mysql';
		}

		// Get the options signature for the database connector
		$signature = md5(serialize($options));

		// If we already have a database connector instance for these options, then just use that
		if (!isset(self::$instances[$signature]))
		{
			// Derive the class name from the driver
			$class = __NAMESPACE__ . '\Driver\\' . ucfirst(strtolower($options['driver']));

			// If the class doesn't exist we have a problem
			if (!class_exists($class))
			{
				throw new RuntimeException('Database driver not available.', 500);
			}

			// Set the new connector to the global instances based on signature
			self::$instances[$signature] = new $class($options);
		}

		return self::$instances[$signature];
	}
public static function getInstance ( $ options = [ ] ) { // Sanitize the database connector options $ options [ 'driver' ] = ( isset ( $ options [ 'driver' ] ) ) ? preg_replace ( '/[^A-Z0-9_\.-]/i' , '' , $ options [ 'driver' ] ) : 'mysql' ; $ options [ 'database' ] = ( isset ( $ options [ 'database' ] ) ) ? $ options [ 'database' ] : null ; $ options [ 'select' ] = ( isset ( $ options [ 'select' ] ) ) ? $ options [ 'select' ] : true ; // @TODO: Eventually remove this? if ( $ options [ 'driver' ] == 'pdo' ) { $ options [ 'driver' ] = 'mysql' ; } // Get the options signature for the database connector $ signature = md5 ( serialize ( $ options ) ) ; // If we already have a database connector instance for these options, then just use that if ( ! isset ( self :: $ instances [ $ signature ] ) ) { // Derive the class name from the driver $ class = __NAMESPACE__ . '\Driver\\' . ucfirst ( strtolower ( $ options [ 'driver' ] ) ) ; // If the class doesn't exist we have a problem if ( ! class_exists ( $ class ) ) { throw new RuntimeException ( 'Database driver not available.' , 500 ) ; } // Set the new connector to the global instances based on signature self :: $ instances [ $ signature ] = new $ class ( $ options ) ; } return self :: $ instances [ $ signature ] ; }
Returns a driver instance based on the given options

There are three global options and then the rest are specific to the database driver:
* The 'driver' option defines which driver class is used for the connection -- the default is 'pdo'.
* The 'database' option determines which database is to be used for the connection.
* The 'select' option determines whether the connector should automatically select the chosen database.

@param   array   $options   Parameters to construct the database driver requested
@return  static
@since   2.0.0
@throws  \Hubzero\Error\Exception\RuntimeException
Returns a driver instance based on the given options