table|false|nil, int, int|string dbPoll(any query, int timeout)
Parameters
| Name | Type | Description |
|---|---|---|
| query | any | The handle dbQuery returned. |
| timeout | int | How many milliseconds to wait: 0 does not wait, -1 waits as long as it takes. |
Returns
nil if the answer has not arrived yet. Otherwise, the rows (one table per row, its columns by name; a NULL column is left out), the number of affected rows and the last inserted id. If the query failed, false, the error code and the message. Once an answer is returned, the handle is freed.
Example
local query = dbQuery(db, "SELECT money FROM players WHERE account = ?", accountId)
local rows, affected, lastId = dbPoll(query, -1)
if rows and rows[1] then
print("money: " .. rows[1].money)
endNoteWaiting blocks the server until the answer arrives; prefer
0 inside a callback.