Modules/MTA-MySQL/mysql rows assoc

From Multi Theft Auto: Wiki
Revision as of 19:22, 14 January 2008 by Ryden (talk | contribs) (New page: __NOTOC__ {{ModuleFunction|MTA-MySQL}} Creates an iterator for the result associative rows. When this function is called, the row cursor is set to the first result row. ==Syntax== <syntaxhighlight lang="lua">[...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Package-x-generic.png 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 associative rows. When this function is called, the row cursor is set to the first result row.

Syntax

iterator mysql_rows_assoc ( MySQLResult result )

Required arguments

  • result: A valid MySQL result

Returns

An iterator function to iterate all the result rows in associative tables.

Example

Example 1: This example prints all the accounts names

local result = mysql_query(handler, "SELECT * FROM account") -- Execute the query
if (result) then
  for result,row in mysql_rows_assoc(result) do
    outputDebugString(row["name"])
  end
  mysql_free_result(result) -- Free the result
end

See also