public static function usingConnectionAttributes($connection, $attributes, callable $function, $context = null)
	{
		static::_connection($connection);
		static::_associate($function, $context);

		return function() use ($connection, $function) {
			$previous = static::setConnectionAttributes($connection, $attributes);
			return static::lastly(function() use ($function) {
				return call_user_func_array($function, func_get_args());
			}, function() use ($previous) {
				static::setConnectionAttributes($connection, $previous);
			});
		};
	}
public static function usingConnectionAttributes($connection, $attributes, callable $function, $context = null)
	{
		static::_connection($connection);
		static::_associate($function, $context);

		return function() use ($connection, $function) {
			$previous = static::setConnectionAttributes($connection, $attributes);
			return static::lastly(function() use ($function) {
				return call_user_func_array($function, func_get_args());
			}, function() use ($previous) {
				static::setConnectionAttributes($connection, $previous);
			});
		};
	}
public static function usingConnectionAttributes ( $ connection , $ attributes , callable $ function , $ context = null ) { static :: _connection ( $ connection ) ; static :: _associate ( $ function , $ context ) ; return function ( ) use ( $ connection , $ function ) { $ previous = static :: setConnectionAttributes ( $ connection , $ attributes ) ; return static :: lastly ( function ( ) use ( $ function ) { return call_user_func_array ( $ function , func_get_args ( ) ) ; } , function ( ) use ( $ previous ) { static :: setConnectionAttributes ( $ connection , $ previous ) ; } ) ; } ; }
Wraps the given function so the connection attributes will be set before the function execution and restored
after that. The previous attribute states are restored even if an exception occurs during function execution
so this function is garanteed to not tamper with the connection state. Returns the function's returned value.

@param string,PDO $connection the database connection name or PDO instance
@param list $attributes the attributes to set
@param callable $function the function to wrap
@param object $context optional, if $query is a function then it will be bound to $context

@return mixed
Wraps the given function so the connection attributes will be set before the function execution and restored after that . The previous attribute states are restored even if an exception occurs during function execution so this function is garanteed to not tamper with the connection state . Returns the function s returned value .