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

		// Derive the class name from the driver.
		$class = '\\Joomla\\Database\\' . ucfirst(strtolower($options['driver'])) . '\\' . ucfirst(strtolower($options['driver'])) . 'Driver';

		// If the class still doesn't exist we have nothing left to do but throw an exception.  We did our best.
		if (!class_exists($class))
		{
			throw new \RuntimeException(sprintf('Unable to load Database Driver: %s', $options['driver']));
		}

		// Create our new Driver connector based on the options given.
		try
		{
			$instance = new $class($options);
		}
		catch (\RuntimeException $e)
		{
			throw new \RuntimeException(sprintf('Unable to connect to the Database: %s', $e->getMessage()));
		}

		return $instance;
	}
public function getDriver($name = 'mysqli', $options = array())
	{
		// Sanitize the database connector options.
		$options['driver']   = preg_replace('/[^A-Z0-9_\.-]/i', '', $name);
		$options['database'] = (isset($options['database'])) ? $options['database'] : null;
		$options['select']   = (isset($options['select'])) ? $options['select'] : true;

		// Derive the class name from the driver.
		$class = '\\Joomla\\Database\\' . ucfirst(strtolower($options['driver'])) . '\\' . ucfirst(strtolower($options['driver'])) . 'Driver';

		// If the class still doesn't exist we have nothing left to do but throw an exception.  We did our best.
		if (!class_exists($class))
		{
			throw new \RuntimeException(sprintf('Unable to load Database Driver: %s', $options['driver']));
		}

		// Create our new Driver connector based on the options given.
		try
		{
			$instance = new $class($options);
		}
		catch (\RuntimeException $e)
		{
			throw new \RuntimeException(sprintf('Unable to connect to the Database: %s', $e->getMessage()));
		}

		return $instance;
	}
public function getDriver ( $ name = 'mysqli' , $ options = array ( ) ) { // Sanitize the database connector options. $ options [ 'driver' ] = preg_replace ( '/[^A-Z0-9_\.-]/i' , '' , $ name ) ; $ options [ 'database' ] = ( isset ( $ options [ 'database' ] ) ) ? $ options [ 'database' ] : null ; $ options [ 'select' ] = ( isset ( $ options [ 'select' ] ) ) ? $ options [ 'select' ] : true ; // Derive the class name from the driver. $ class = '\\Joomla\\Database\\' . ucfirst ( strtolower ( $ options [ 'driver' ] ) ) . '\\' . ucfirst ( strtolower ( $ options [ 'driver' ] ) ) . 'Driver' ; // If the class still doesn't exist we have nothing left to do but throw an exception.  We did our best. if ( ! class_exists ( $ class ) ) { throw new \ RuntimeException ( sprintf ( 'Unable to load Database Driver: %s' , $ options [ 'driver' ] ) ) ; } // Create our new Driver connector based on the options given. try { $ instance = new $ class ( $ options ) ; } catch ( \ RuntimeException $ e ) { throw new \ RuntimeException ( sprintf ( 'Unable to connect to the Database: %s' , $ e -> getMessage ( ) ) ) ; } return $ instance ; }
Method to return a Driver instance based on the given options. There are three global options and then
the rest are specific to the database driver. 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.

Instances are unique to the given options and new objects are only created when a unique options array is
passed into the method.  This ensures that we don't end up with unnecessary database connection resources.

@param   string  $name     Name of the database driver you'd like to instantiate
@param   array   $options  Parameters to be passed to the database driver.

@return  DatabaseDriver  A database driver object.

@since   1.0
@throws  \RuntimeException
Method to return a Driver instance based on the given options . There are three global options and then the rest are specific to the database driver . 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 .