M MY Multiplayer: Wiki
Side
Kind

dbPoll

Server

Reads the answer of a dbQuery query, waiting for it if needed.

table|false|nil, int, int|string dbPoll(any query, int timeout)

Parameters

NameTypeDescription
queryanyThe handle dbQuery returned.
timeoutintHow 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)
end
NoteWaiting blocks the server until the answer arrives; prefer 0 inside a callback.

See also