Added support for odbc connections.

This commit is contained in:
Taylor Otwell 2011-07-19 11:16:55 -07:00
parent f7fc01304c
commit e70726caea
1 changed files with 16 additions and 2 deletions

View File

@ -34,6 +34,9 @@ public static function connect($connection)
case 'mysql': case 'mysql':
case 'pgsql': case 'pgsql':
return static::connect_to_server($config); return static::connect_to_server($config);
case 'odbc':
return static::connect_to_odbc($config);
} }
throw new \Exception('Database driver '.$config->driver.' is not supported.'); throw new \Exception('Database driver '.$config->driver.' is not supported.');
@ -45,7 +48,7 @@ public static function connect($connection)
* SQLite database paths can be specified either relative to the application/db * SQLite database paths can be specified either relative to the application/db
* directory, or as an absolute path to any location on the file system. * directory, or as an absolute path to any location on the file system.
* *
* @param array $config * @param object $config
* @return PDO * @return PDO
*/ */
private static function connect_to_sqlite($config) private static function connect_to_sqlite($config)
@ -67,7 +70,7 @@ private static function connect_to_sqlite($config)
/** /**
* Connect to a MySQL or PostgreSQL database server. * Connect to a MySQL or PostgreSQL database server.
* *
* @param array $config * @param object $config
* @return PDO * @return PDO
*/ */
private static function connect_to_server($config) private static function connect_to_server($config)
@ -89,6 +92,17 @@ private static function connect_to_server($config)
return $connection; return $connection;
} }
/**
* Connect to an ODBC data source.
*
* @param object $config
* @return PDO
*/
private static function connect_to_odbc($config)
{
return new \PDO($config->dsn, $config->username, $config->password, static::$options);
}
/** /**
* Get the configuration options for a database connection. * Get the configuration options for a database connection.
* *