1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-04 05:07:36 +02:00

dibi: named connections and activate() are deprecated (BC break)

This commit is contained in:
David Grudl
2015-01-13 06:49:49 +01:00
parent 9a95edf003
commit a923ce7ecb

View File

@@ -86,12 +86,14 @@ class dibi
/** /**
* Creates a new DibiConnection object and connects it to specified database. * Creates a new DibiConnection object and connects it to specified database.
* @param mixed connection parameters * @param mixed connection parameters
* @param string connection name
* @return DibiConnection * @return DibiConnection
* @throws DibiException * @throws DibiException
*/ */
public static function connect($config = array(), $name = 0) public static function connect($config = array(), $name = 0)
{ {
if ($name) {
trigger_error(__METHOD__ . '(): named connections are deprecated.', E_USER_DEPRECATED);
}
return self::$connection = self::$registry[$name] = new DibiConnection($config, $name); return self::$connection = self::$registry[$name] = new DibiConnection($config, $name);
} }
@@ -118,7 +120,6 @@ class dibi
/** /**
* Retrieve active connection. * Retrieve active connection.
* @param string connection registy name
* @return DibiConnection * @return DibiConnection
* @throws DibiException * @throws DibiException
*/ */
@@ -132,6 +133,8 @@ class dibi
return self::$connection; return self::$connection;
} }
trigger_error(__METHOD__ . '(): named connections are deprecated.', E_USER_DEPRECATED);
if (!isset(self::$registry[$name])) { if (!isset(self::$registry[$name])) {
throw new DibiException("There is no connection named '$name'."); throw new DibiException("There is no connection named '$name'.");
} }
@@ -152,13 +155,11 @@ class dibi
/** /**
* Change active connection. * @deprecated
* @param string connection registy name
* @return void
* @throws DibiException
*/ */
public static function activate($name) public static function activate($name)
{ {
trigger_error(__METHOD__ . '() is deprecated.', E_USER_DEPRECATED);
self::$connection = self::getConnection($name); self::$connection = self::getConnection($name);
} }