-
Notifications
You must be signed in to change notification settings - Fork 1
MySQL Module ConnectionClass query
DizzasTeR edited this page Jan 30, 2021
·
3 revisions
Executes a mysql query and returns the result as a table
int MySQLConnection:query([function callback, ] string query [, ...optionalParameters])- optional string function — Function to call with the number of affected rows (OPTIONAL)
- string query — The query to execute
- optional optionalParameters — Forward any extra parameters with the query (Used for prepared statements)
table - Query result. May be an empty table if no matching results. nil if the query failed
if MySQLTests.query then
local result = connection:query("SELECT * FROM test_table WHERE name = ?", {"dizzo"})
print("Got #"..#result.." results")
if #result > 0 then
local row = result[1]
print("["..type(row.id).."] "..row.id.." => ["..type(row.name).."] "..row.name)
end
end