Modules/MTA-MySQL/mysql fetch lengths: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ Returns a table containing the length of the values of the last retreived row. If you didn't retreive any row or you are in the end of the result set, it returns nil. ==Syntax==...)
 
No edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{ModuleFunction|MTA-MySQL}}
Returns a table containing the length of the values of the last retreived row. If you didn't retreive any row or you are in the end of the result set, it returns nil.
Returns a table containing the length of the values of the last retreived row. If you didn't retreive any row or you are in the end of the result set, it returns nil.



Revision as of 18:03, 14 January 2008


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

Returns a table containing the length of the values of the last retreived row. If you didn't retreive any row or you are in the end of the result set, it returns nil.

Syntax

table mysql_fetch_lengths ( MySQLResult result )

Required arguments

  • result: A valid MySQL result

Returns

A table with the length of the values of the last retreived row.

Example

Example 1: This example shows the length of an account name

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) -- Return the resulting row
  local lengths = mysql_fetch_lengths(result) -- Retreive the lengths of the result fields
  outputDebugString("The length of " .. row[1] .. " is " .. lengths[1])
  mysql_free_result(result) -- Free the result
end

See also