Guest User

Untitled

a guest
Jul 14th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.81 KB | None | 0 0
  1. -- connection functions
  2. local function connect( )
  3.  
  4.     local user = "BLA_server"
  5.     local password = "BLA"
  6.    
  7.     connection = dbConnect ( "MySQL", "dbname=BLA_server;host=159.253.0.5;port=3306", user, password )
  8.     if connection then
  9.         return true
  10.     else
  11.         outputDebugString ( "Connection with the MySQL database failed", 1 )
  12.         return false
  13.     end
  14. end
  15.  
  16.  
  17.  
  18. local function query( str, ... )
  19.  
  20.     if ( ... ) then
  21.         local t = { ... }
  22.         for k, v in ipairs( t ) do
  23.             t[ k ] = escape_string( tostring( v ) ) or ""
  24.         end
  25.         str = str:format( unpack( t ) )
  26.     end
  27.    
  28.     local result = dbQuery( connection, str )
  29.     if result then
  30.         for num = 1, max_results do
  31.             if not results[ num ] then
  32.                 results[ num ] = { r = result, q = str }
  33.                 return num
  34.             end
  35.         end
  36.         dbQuery( result )
  37.         return false
  38.     end
  39.     return false
  40. end
Add Comment
Please, Sign In to add comment