DbPoll

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search

dbPoll

Reads the current result of an asynchronous database query.

Syntax

table dbPoll(DatabaseQuery query [, int timeoutMs = 0 [, bool multipleResults = false]])

Parameters

Name Type Required Description
query DatabaseQuery yes The handle returned by dbQuery.
timeoutMs int no Maximum wait in milliseconds. Use 0 for a non-blocking check.
multipleResults bool no Reserved for multiple result sets; currently unsupported.

Returns

Returns nil while pending; false, errorCode, errorMessage on failure; or rows, rowOrAffectedCount, lastInsertId on success.

Examples

Poll a query without blocking:

local rows, count = dbPoll(query, 0)
if rows == nil then
    print("Query is still running")
elseif rows == false then
    outputDebugString("Query failed", 1)
else
    print("Rows:", count)
end

Notes

  • Available only in server-side resource scripts.
  • SQL NULL values are represented as false in result rows. Infinite blocking polls are not supported.