dbPoll
This function checks the progress of a database query.
If a column contained a number it is returned as a number, this includes things which were stored as string but are numbers such as "1" would be returned as 1.
It is strongly recommended to use this function in callback, as presented in the Example 10.
OOP Syntax Help! I don't understand this!
- Method:db-query:poll(...)
Syntax
table|false dbPoll ( db-query queryHandle, int timeout, [ bool multipleResults = false ] )Required Arguments
- queryHandle: A query handle previously returned from dbQuery.
- timeout: How many milliseconds to wait for a result. Use 0 for an 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 executeSQLQuery.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.
- multipleResults (default: false): Set to true to enable the return values from multiple queries.
Returns
- table|false: result
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).
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.
Returns a table with the result of the query when the query has successfully completed. This automatically frees the query handle, so you do not have to call dbFree. If multipleResults is set to true, it will first return a table pertaining to one query, followed by the results for that query and so on for the next queries. This also returns extra values: number of affected rows and last insert id.
The table is of the format
{
{ colname1=value1, colname2=value2, ... },
{ colname1=value3, colname2=value4, ... },
...
}
Code Examples
This example waits until a result is ready:
local result = dbPoll(qh, -1)