/**
  *  This function will return a YDDatabaseDriver instance for the named database instance. If no instance is
  *  given, the one with the name "default" will be used. You can use database instance objects too.
  *
  *  @param $name    (optional) The name or object of the database instance. Defaults to "default".
  *
  *  @returns    An instance of YDDatabaseDriver
  *
  *  @static
  */
 function getNamedInstance($name = 'default')
 {
     // Check if name is a YDDatabaseDriver object
     if (is_object($name)) {
         return $name;
     }
     // Check if the global array exists
     YDDatabase::_initNamedInstances();
     // Trigger an error if the named instance doesn't exist.
     if (!array_key_exists(strtolower($name), $GLOBALS['YD_DB_INSTANCES'])) {
         trigger_error('The named database instance "' . $name . '" is not defined.', YD_ERROR);
     }
     // Get the parameters
     $params = $GLOBALS['YD_DB_INSTANCES'][strtolower($name)];
     // Return the right named instance
     return YDDatabase::getInstance($params[0], $params[1], $params[2], $params[3], $params[4]);
 }