Es formatqv

From EventScripts Community Encyclopedia


Overview

Syntax: es_formatqv <variable> <format-string> [token1] [token2] [token3] [...] [token9]

Note: Command parameters are described inside the < and > characters. Optional parameters are contained within [ and ] characters.

Variation of this command that doesn't expand variables: es_xformatqv

Description

Formats a string according to the format-string escaping all special characters to be used in an SQL query, and stores it into the variable.

Parameters

  • variable - Variable to store the string into.
  • format-string - String that you would like to place the parameters into. Will place tokenX in format-string in place of %X.
  • tokenX - Tokens that will be placed in the string. The tokens must be variable names! Can have any number of tokens from 0 to 9.


Examples

This example demonstrates the usage of es_formatqv

es_xsetinfo querystring 0
es_xsetinfo pname 0
es_getplayername pname event_var(userid)
// Name can contain some hazardous characters for SQL queries, es_formatqv takes care of them for you:
es_xformatqv querystring "INSERT INTO stable VALUES ('%1');" pname
es_sql query sampledb server_var(querystring)


Notes

  • The maximum number of tokens supported are nine.
  • For more details, see the sister command es_formatv which is identical to this command except that it does not escape special characters.
  • First time available in EventScripts v1.5


See also

blog comments powered by Disqus