-- USTAWIENIA
local SQL_DB="db_32646"
local SQL_USER="db_32646"
local SQL_PASS="*********"
local SQL_HOST="178.xx.xx.xx"
local SQL_PORT= 3306
connection = nil
connection2 = nil
conn=true
conn2=true
function filtr(...) return true end
-- Logi z po??cze? z baz? danych
local time = getRealTime()
local tn=string.format("%04d-%02d-%02d'%02d %02d %02d-%02d.txt",time.year+1900,time.month+1,time.monthday,time.hour,time.minute,time.second,math.random(1,99))
local fh=fileCreate("logi/"..tn)
function outputLog(text)
if (text and fh) then
local time = getRealTime()
local ts=string.format("%04d-%02d-%02d=%02d:%02d:%02d> ",time.year+1900,time.month+1,time.monthday,time.hour,time.minute,time.second)
fileWrite(fh,ts..text.."\n")
fileFlush(fh)
end
end
outputLog("Rozpoczynianie logowania polece? . . .")
outputLog("Logowanie polece? rozpocz?te!")
-- ??CZENIE Z BAZ? DANYCH
function connectionDB()
if conn ~= true then return end
connection=dbConnect("mysql","dbname="..SQL_DB..";host="..SQL_HOST.."",""..SQL_USER.."",""..SQL_PASS.."","share=1")
if not connection then
outputDebugString("dbConnect: NIE UDA?O SI? PO??CZY? Z BAZ? DANYCH!!!!!",3,255,0,0)
else
outputDebugString("dbConnect: Prawid?owo po??czono z baz? danych!",3,255,0,0)
GdbQuery("SET NAMES utf8")
end
end addEventHandler("onResourceStart",resourceRoot,connectionDB)
function connectionDB2()
if conn2 ~= true then return end
connection2 = mysql_connect(SQL_HOST,SQL_USER,SQL_PASS,SQL_DB,3306)
if not connection2 then
outputDebugString("dbConnect2: NIE UDA?O SI? PO??CZY? Z BAZ? DANYCH!!!!!",3,255,0,0)
else
outputDebugString("dbConnect2: Prawid?owo po??czono z baz? danych!",3,255,0,0)
zapytanie("SET NAMES utf8")
end
end
function keepAlive()
if not connection2 then return end
if (not mysql_ping(connection2)) then
outputServerLog("Po??czenie z baz? danych zosta?o zerwane, trwa ponowne nawi?zywanie . . .")
connectionDB2()
end
end
addEventHandler("onResourceStart",resourceRoot,function()
connectionDB2()
setTimer(keepAlive,15000,0)
end)
-------------------------- BRAK MODU?U --------------------------
function GdbExec(...)
if conn ~= true or not connection then return end
outputLog(...)
local hand=dbExec(connection, ...) return hand
end
function GdbExec2(...)
if conn ~= true or not connection then return end
outputLog(tostring(...))
if filtr(...) then
local tab={...}
local hand=dbExec(connection, ...) return hand
end
end
function GdbPoll(query)
if conn ~= true or not connection then return end
local poll=dbPoll(query,-1) return poll
end
function GdbQuery(...)
if conn ~= true or not connection then return end
outputLog(tostring(...))
if filtr(...) then
local query=dbQuery(connection, ...) return query
end
end
-------------------------- Z MODU?EM --------------------------
function esc(value)
if conn2 ~= true or not connection2 then return end
outputLog("MySQL escape string: "..value)
return mysql_escape_string(connection2,value)
end
function pobierzTabeleWynikow(tabela)
if conn2 ~= true or not connection2 then return end
if filtr(tabela) then
local result=mysql_query(connection2,"SELECT * FROM `"..tabela.."` WHERE do>now()")
outputLog("SELECT * FROM `"..tabela.."` WHERE do>now()")
if (not result) then
outputDebugString("mysql_query failed: ("..mysql_errno(connection2)..") "..mysql_error(connection2))
return nil
end
local tabela={}
for result,row in mysql_rows_assoc(result) do
table.insert(tabela,row)
end
mysql_free_result(result)
return tabela
end
end
function zapytanie(query,costam)
if not costam then
if conn2 ~= true or not connection2 then return end
if filtr(query) then
local result=mysql_query(connection2,query)
outputLog(tostring(query))
if (result) then mysql_free_result(result) end
return
end
else
local result=mysql_query(connection2,query)
outputLog(query)
if (not result) then
outputDebugString("mysql_query failed: (" .. mysql_errno(connection2) .. ") " .. mysql_error(connection2))
return nil
end
local tabela={}
for result,row in mysql_rows_assoc(result) do
table.insert(tabela,row)
end
mysql_free_result(result)
return tabela
end
Wskazuje na zerow? warto??, czyli nie wyszukuje podanych eksport?w. Czy w meta.xml gdzie masz po??czenie z baz? danych jest takie co? jak GdbQuery? R?wnie? posiadasz modu?y?
A gdzie je doda?, albo inaczej, co mam teraz post?pi?, bo rozumiem, co mi da?e?, tylko co gdzie jak da?, ?eby mia?o to r?ce i nogi
[ Dodano: 2018-04-15, 19:37 ]
a co jak nie mam tego modelesu? Bo nie posiadam, to co teraz?
[ Dodano: 2018-04-16, 17:02 ]
Modu?u nie posiadam, ju? mia?em nadziej?, teraz pytanie mam odno?nie jak mam "zrobi?" taki modu?, albo czy mo?na bez tego zrobi??
Nie możesz pisać nowych tematów Nie możesz odpowiadać w tematach Nie możesz zmieniać swoich postów Nie możesz usuwać swoich postów Nie możesz głosować w ankietach