Modules/MTA-MySQL/mysql fields: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
<pageclass class="#AA7592" subcaption="MTA-MySQL Module"></pageclass> | |||
__NOTOC__ | __NOTOC__ | ||
{{ModuleFunction|MTA-MySQL}} | {{ModuleFunction|MTA-MySQL}} | ||
Line 33: | Line 34: | ||
==See also== | ==See also== | ||
{{Modules/MTA-MySQL/Result_functions}} | {{Modules/MTA-MySQL/Result_functions}} | ||
'''Bold text''' |
Revision as of 18:02, 5 January 2011
This function is provided by the external module MTA-MySQL. You must install this module to use this function. | |
Creates an iterator for the result fields. When this function is called, the field cursor is set to the first field.
Syntax
iterator mysql_fields ( MySQLResult result )
Required arguments
- result: A valid MySQL result
Returns
An iterator function to iterate all the result fields.
Example
Example 1: This example shows how to print the rows of a result set showing the field name.
local result = mysql_query(handler, "SELECT * FROM account") -- Execute the query for result,row in mysql_rows(result) do -- Iterate through all the result rows local i = 1 for result,field in mysql_fields(result) do if (row[i] ~= mysql_null()) then outputDebugString("row[" .. field["name"] .. "] = " .. row[i]) else outputDebugString("row[" .. field["name"] .. "] = NULL") end i = i + 1 end end mysql_free_result(result) -- Free the result
See also
- mysql_data_seek
- mysql_fetch_field
- mysql_fields
- mysql_fetch_lengths
- mysql_fetch_row
- mysql_rows
- mysql_fetch_assoc
- mysql_rows_assoc
- mysql_field_length
- mysql_field_name
- mysql_field_seek
- mysql_field_tell
- mysql_num_fields
- mysql_num_rows
- mysql_result
- mysql_free_result
- mysql_null
Bold text