public static function getConnection( $hostname, $dbname ) {
		if ( isset( self::$dbConnections[ $hostname ] ) ) {
			$conn = self::$dbConnections[ $hostname ];
		} else {
			$section = new kfLogSection( __METHOD__ );
			try {
				$conn = new LoggedPDO(
					'mysql:host=' . $hostname . ';dbname=' . $dbname . '_p;charset=utf8',
					kfDbUsername(),
					kfDbPassword()
				);
			    $conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
			} catch ( Exception $e ) {
				throw new Exception( "Connection to '$hostname' failed: " . $e->getMessage() );
			}
			self::$dbConnections[ $hostname ] = $conn;
			return $conn;
		}

		// Re-used connection, switch database first.
		self::selectDB( $conn, $dbname );

		return $conn;
	}