Modules/MTA-MySQL/mysql fields: Difference between revisions
Jump to navigation
Jump to search
(New page: __NOTOC__ Creates an iterator for the result fields. When this function is called, the field cursor is set to the first field. ==Syntax== <syntaxhighlight lang="lua"> iterator mysql_fields ( MySQLResult...) |
(No difference)
|
Revision as of 16:54, 14 January 2008
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