Példa:
function getSQLData()
return \"dbname=la_rp;host=Host\", \"felhasználó\", \"Jelszó\", \"share=1\"
end
function connectToDb()
local mysqlConnect = dbConnect(\"mysql\",getSQLData())
if not (mysqlConnect) then
outputDebugString(\"Nem tudtam csatlakozni a MYSQL-hez.\")
else
outputDebugString(\"Sikeresen csatlakoztam a MYSQL-hez.\")
end
end
addEventHandler(\"onResourceStart\", getResourceRootElement(getThisResource()), connectToDb, false)
function query_free(str)
local queryresult = query(str)
if not (queryresult == false) then
free_result(queryresult)
return true
end
return false
end
function free_result(resultid)
if (not resultPool[resultid]) then
return false
end
mysql_free_result(resultPool[resultid])
table.remove(resultPool, resultid)
table.remove(queryPool, resultid)
return nil
end
function fetch_assoc(resultid)
if (not resultPool[resultid]) then
return false
end
return mysql_fetch_assoc(resultPool[resultid])
end