Modules/MTA-MySQL/mysql field length: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ {{ModuleFunction|MTA-MySQL}} Returns the length of a given field in the last retreived row. The offset of the field must be an integer between '''1''' and '''[[Modules/MTA-MySQL/...)
 
mNo edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<pageclass class="#AA7592" subcaption="MTA-MySQL Module"></pageclass>
__NOTOC__
__NOTOC__
{{ModuleFunction|MTA-MySQL}}
{{ModuleFunction|MTA-MySQL}}
Returns the length of a given field in the last retreived row. The offset of the field must be an integer between '''1''' and '''[[Modules/MTA-MySQL/mysql_num_rows/mysql_num_rows()]]'''
Returns the length of a given field in the last retreived row. The offset of the field must be an integer between '''1''' and '''[[Modules/MTA-MySQL/mysql_num_fields|mysql_num_fields()]]'''


==Syntax==
==Syntax==
Line 12: Line 13:


===Returns===
===Returns===
The given row data length.
The given field data length.


===Example===
===Example===

Latest revision as of 18:05, 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.

Returns the length of a given field in the last retreived row. The offset of the field must be an integer between 1 and mysql_num_fields()

Syntax

int mysql_field_length ( MySQLResult result, int offset )

Required arguments

  • result: A valid MySQL result
  • offset: A valid offset

Returns

The given field data length.

Example

Example 1:

local result = mysql_query(handler, "SELECT name FROM account WHERE id='1' LIMIT 1") -- Execute the query
if (result) then
  local row = mysql_fetch_row(result)
  local length = mysql_field_length(result, 1)
  outputDebugString("The length of " .. row[1] .. " is " .. length)
  mysql_free_result(result) -- Free the result
end

See also