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

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ Returns a table containing the current row of the last executed query. You can call this function repeatedly to retreive all the result rows. When there aren't more rows in the r...)
 
mNo edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<pageclass class="#AA7592" subcaption="MTA-MySQL Module"></pageclass>
__NOTOC__
__NOTOC__
{{ModuleFunction|MTA-MySQL}}
Returns a table containing the current row of the last executed query. You can call this function repeatedly to retreive all the result rows. When there aren't more rows in the result it returns nil. You can go to a specific row calling [[Modules/MTA-MySQL/mysql_data_seek|mysql_data_seek()]]
Returns a table containing the current row of the last executed query. You can call this function repeatedly to retreive all the result rows. When there aren't more rows in the result it returns nil. You can go to a specific row calling [[Modules/MTA-MySQL/mysql_data_seek|mysql_data_seek()]]


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
table mysql_fetch_rows ( MySQLResult result )
table mysql_fetch_row ( MySQLResult result )
</syntaxhighlight>
</syntaxhighlight>
===Required arguments===
===Required arguments===

Latest revision as of 18:04, 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 a table containing the current row of the last executed query. You can call this function repeatedly to retreive all the result rows. When there aren't more rows in the result it returns nil. You can go to a specific row calling mysql_data_seek()

Syntax

table mysql_fetch_row ( MySQLResult result )

Required arguments

  • result: A valid MySQL result

Returns

A table with the current row

Example

Example 1: This example shows the name of all the registered accounts

local result = mysql_query(handler, "SELECT name FROM account") -- Execute the query
if (result) then
  while true do
    local row = mysql_fetch_row(result)
    if (not row) then break end

    outputDebugString(row[1])
  end
  mysql_free_result(result) -- Free the result
end

See also