diff options
Diffstat (limited to 'includes/database/database.inc')
-rw-r--r-- | includes/database/database.inc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/includes/database/database.inc b/includes/database/database.inc index 94517f002..8d6abb844 100644 --- a/includes/database/database.inc +++ b/includes/database/database.inc @@ -194,6 +194,17 @@ abstract class DatabaseConnection extends PDO { protected $target = NULL; /** + * The key representing this connection. + * + * The key is a unique string which identifies a database connection. A + * connection can be a single server or a cluster of master and slaves (use + * target to pick between master and slave). + * + * @var string + */ + protected $key = NULL; + + /** * The current database logging object for this connection. * * @var DatabaseLog @@ -470,6 +481,28 @@ abstract class DatabaseConnection extends PDO { } /** + * Tells this connection object what its key is. + * + * @param $target + * The key this connection is for. + */ + public function setKey($key) { + if (!isset($this->key)) { + $this->key = $key; + } + } + + /** + * Returns the key this connection is associated with. + * + * @return + * The key of this connection. + */ + public function getKey() { + return $this->key; + } + + /** * Associates a logging object with this connection. * * @param $logger @@ -1539,6 +1572,7 @@ abstract class Database { require_once DRUPAL_ROOT . '/includes/database/' . $driver . '/database.inc'; $new_connection = new $driver_class(self::$databaseInfo[$key][$target]); $new_connection->setTarget($target); + $new_connection->setKey($key); // If we have any active logging objects for this connection key, we need // to associate them with the connection we just opened. |