From 75fed365893ab883b78004d4645a38fd22f41664 Mon Sep 17 00:00:00 2001 From: zYne Date: Sun, 24 Sep 2006 10:00:44 +0000 Subject: [PATCH] added static method driverName --- draft/DB.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/draft/DB.php b/draft/DB.php index adba4d0ed..3018047d7 100644 --- a/draft/DB.php +++ b/draft/DB.php @@ -196,9 +196,19 @@ class Doctrine_DB2 implements Countable, IteratorAggregate { } return self::$instances[$md5]; } - - public static function driverName() { - + /** + * driverName + * converts a driver name like (oracle) to appropriate PDO + * driver name (oci8 in the case of oracle) + * + * @param string $name + * @return string + */ + public static function driverName($name) { + if(isset(self::$driverMap[$name])) + return self::$driverMap[$name]; + + return $name; } /** * parseDSN @@ -207,6 +217,7 @@ class Doctrine_DB2 implements Countable, IteratorAggregate { * @return array Parsed contents of DSN */ function parseDSN($dsn) { + // silence any warnings $parts = @parse_url($dsn); $names = array('scheme', 'host', 'port', 'user', 'pass', 'path', 'query', 'fragment'); @@ -220,9 +231,8 @@ class Doctrine_DB2 implements Countable, IteratorAggregate { throw new Doctrine_DB_Exception('Empty data source name'); $drivers = self::getAvailableDrivers(); - - if(isset(self::$driverMap[$parts['scheme']])) - $parts['scheme'] = self::$driverMap[$parts['scheme']]; + + $parts['scheme'] = self::driverName($parts['scheme']); if( ! in_array($parts['scheme'], $drivers)) throw new Doctrine_DB_Exception('Driver '.$parts['scheme'].' not availible or extension not loaded');