Guest User

Untitled

a guest
Mar 20th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.24 KB | None | 0 0
  1. local SQL
  2.  
  3. local function connect()
  4.     -- w ponizszej linii uzupelnij dane autoryzacji
  5.     SQL = dbConnect("mysql", "dbname=db_41935;host=87.98.236.134", "db_41935","******************","share=1")
  6.     if (not SQL) then
  7.         outputServerLog("BRAK POLACZENIA Z BAZA DANYCH!")
  8.     else
  9.         zapytanie("SET NAMES utf8;")
  10.     end
  11.  
  12. end
  13.  
  14. addEventHandler("onResourceStart",resourceRoot, connect)
  15.  
  16. function pobierzTabeleWynikow(...)
  17.     local h=dbQuery(SQL,...)
  18.     if (not h) then
  19.         return nil
  20.     end
  21.     local rows = dbPoll(h, -1)
  22.     return rows
  23. end
  24.  
  25. function pobierzWyniki(...)
  26.     local h=dbQuery(SQL,...)
  27.     if (not h) then
  28.         return nil
  29.     end
  30.     local rows = dbPoll(h, -1)
  31.     if not rows then return nil end
  32.     return rows[1]
  33. end
  34.  
  35. function zapytanie(...)
  36.     local h=dbQuery(SQL,...)
  37.     local result,numrows=dbPoll(h,-1)
  38.     return numrows
  39. end
  40.  
  41. --[[
  42. function insertID()
  43.     return mysql_insert_id(SQL)
  44. end
  45.  
  46. function affectedRows()
  47.     return mysql_affected_rows(SQL)
  48. end
  49. ]]--
  50.  
  51. function fetchRows(query)
  52.     local result=mysql_query(SQL,query)
  53.     if (not result) then return nil end
  54.     local tabela={}
  55.  
  56.     while true do
  57.         local row = mysql_fetch_row(result)
  58.         if (not row) then break end
  59.         table.insert(tabela,row)
  60.     end
  61.     mysql_free_result(result)
  62.     return tabela
  63. end
Add Comment
Please, Sign In to add comment