14 require_once dirname(__FILE__).
'/DSN.inc';
15 require_once dirname(__FILE__).
'/DSNPool.inc';
38 private static $_dsnpool_supported_conns = Array(
'db',
'dbsearch');
45 private static $_dsns = Array();
57 public static function addDSN($conn_id =
'db', Array $dsn)
60 if (isset(self::$_dsns[$conn_id])) {
65 self::_parseDSN($dsn);
68 if (self::_isDSNArray($dsn)) {
70 if (!self::isDSNPoolSupportedConnection($conn_id)) {
71 throw new DALException(
"The connection '$conn_id' does not support DSN Pool.");
76 $new_dsn =
new DSN($dsn);
80 self::$_dsns[$conn_id] = $new_dsn;
96 public static function getDSN($conn_id =
'db')
98 if (!isset(self::$_dsns[$conn_id])) {
102 return self::$_dsns[$conn_id]->getDSN();
116 if (self::isDSNPool($conn_id)) {
117 self::$_dsns[$conn_id]->registerFailureDSN();
132 if (!isset(self::$_dsns[$conn_id])) {
136 return (self::$_dsns[$conn_id] instanceof
DSNPool);
150 return in_array($conn_id, self::$_dsnpool_supported_conns);
163 private static function _parseDSN(&$dsn)
165 if (self::_isDSNArray($dsn) && (count($dsn) == 1)) {
179 private static function _isDSNArray($dsn)
181 return !isset($dsn[
'DSN']);