Modules/MTA-MySQL/mysql hex string: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ Converts a string to an hexadecimal representation of it. It is useful to insert binary data in blob fields, or to retreive and show it in your resources. It doesn't append '0x' ...)
 
mNo edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
<pageclass class="#AA7592" subcaption="MTA-MySQL Module"></pageclass>
__NOTOC__
__NOTOC__
{{ModuleFunction|MTA-MySQL}}
Converts a string to an hexadecimal representation of it. It is useful to insert binary data in blob fields, or to retreive and show it in your resources. It doesn't append '0x' or 'X' to the retreived string, the programmer must add it.
Converts a string to an hexadecimal representation of it. It is useful to insert binary data in blob fields, or to retreive and show it in your resources. It doesn't append '0x' or 'X' to the retreived string, the programmer must add it.



Latest revision as of 17:44, 5 January 2011


Package-x-generic.png This function is provided by the external module MTA-MySQL. You must install this module to use this function.

Converts a string to an hexadecimal representation of it. It is useful to insert binary data in blob fields, or to retreive and show it in your resources. It doesn't append '0x' or 'X' to the retreived string, the programmer must add it.

Syntax

string mysql_hex_string ( string theString )

Required arguments

  • theString: The string to convert

Returns

An hexadecimal formatted string.

Example

Example 1: This function receives a string with a binary file content and stores it in a blob field of the database.

function savePlayerAvatar(playerName, imgRawData)
  local imgHexData = mysql_hex_string(imgRawData)
  mysql_query(handler, "UPDATE account SET avatar='0x" .. imgHexData .. "' WHERE name='" .. playerName .. "'")
end

See also