mirror of
https://github.com/MinetestForFun/mysql_auth.git
synced 2025-01-08 00:50:25 +01:00
Put table existence check into a function
This commit is contained in:
parent
aaea6cd076
commit
5c758ba5b1
11
init.lua
11
init.lua
@ -184,13 +184,18 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local auth_table_created
|
local function table_exists(name)
|
||||||
do -- Auth table existence check and setup
|
|
||||||
conn:query("SHOW TABLES LIKE '" .. tables.auths.name .. "'")
|
conn:query("SHOW TABLES LIKE '" .. tables.auths.name .. "'")
|
||||||
local res = conn:store_result()
|
local res = conn:store_result()
|
||||||
local exists = (res:row_count() ~= 0)
|
local exists = (res:row_count() ~= 0)
|
||||||
res:free()
|
res:free()
|
||||||
if not exists then
|
return exists
|
||||||
|
end
|
||||||
|
thismod.table_exists = table_exists
|
||||||
|
|
||||||
|
local auth_table_created
|
||||||
|
do -- Auth table existence check and setup
|
||||||
|
if not table_exists(tables.auths.name) then
|
||||||
-- Auth table doesn't exist, create it
|
-- Auth table doesn't exist, create it
|
||||||
local S = tables.auths.schema
|
local S = tables.auths.schema
|
||||||
conn:query('CREATE TABLE ' .. tables.auths.name .. ' (' ..
|
conn:query('CREATE TABLE ' .. tables.auths.name .. ' (' ..
|
||||||
|
Loading…
Reference in New Issue
Block a user