DbPoll: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
OpenIDUser32 (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server function}} | {{Server function}} | ||
{{New feature|3.0120|1.2| | {{New feature/item|3.0120|1.2|3328| | ||
'''Available only in MTA SA 1.1.1 r3328 and onwards''' | '''Available only in MTA SA 1.1.1 r3328 and onwards''' | ||
}} | }} |
Revision as of 11:02, 22 November 2011
Available only in MTA SA 1.1.1 r3328 and onwards This function checks the progress of a database query.
Syntax
table dbPoll ( handle queryHandle, int timeout )
Required Arguments
- queryHandle: A query handle previously returned from dbQuery
- timeout: How many milliseconds to wait for a result. Use 0 for and instant response (which may return nil). Use -1 to wait until a result is ready. Note: A wait here will freeze the entire server just like the executeSQL* functions
Returns
- nil: Returns nil if the query results are not yet ready. You should try again in a little while. (If you give up waiting for a result, be sure to call dbFree)
- false Returns false if the query string contained an error, the connection has been lost or the query handle is incorrect. This automatically frees the query handle, so you do not have to call dbFree.
- This also returns two extra values: error code and error message. See the example on how to retrieve them,
- table: Returns a table when the results are ready. This automatically frees the query handle, so you do not have to call dbFree.
- This also returns an extra value: number of affected rows
Example
This example waits until a result is ready:
local result = dbPoll ( qh, -1 )
This example shows the possible return values:
local result, numrows, errmsg = dbPoll ( qh, -1 ) if result == nil then outputConsole( "dbPoll result not ready yet" ) elseif result == false then outputConsole( "dbPoll failed. Error code: " .. tostring(numrows) .. " Error message: " .. tostring(errmsg) ) else outputConsole( "dbPoll succeeded. Number of affected rows: " .. tostring(numrows) ) end
Requirements
This template will be deleted.
See Also