Advertisement
Guest User

Untitled

a guest
Sep 12th, 2010
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.03 KB | None | 0 0
  1. require ( "mysqloo" )
  2.  
  3. function mySQLConnect ( sqlServer , sqlUsername , sqlPassword , sqlDatabase , sqlPort )
  4.     sqlPort = sqlPort or 3306
  5.    
  6.     if ( !mySQL.hasConnection ) then
  7.         mySQLConnection = mysqloo.connect ( sqlServer , sqlUsername , sqlPassword , sqlDatabase , sqlPort )
  8.        
  9.         mySQLConnection.onConnected = function()
  10.             print ( "mySQL: Successfully Connected!" )
  11.             mySQL.hasConnection = true
  12.         end
  13.        
  14.         mySQLConnection:connect()
  15.         mySQLConnection:wait()
  16.     end
  17. end
  18.  
  19. function mySQLQuery ( Query )
  20.     if ( mySQL.hasConnection ) then
  21.         if ( Query ) then
  22.             if ( mySQLConnection:status() == 0 ) then
  23.                 print ("STATUS = 0 -- CONNECTED")
  24.                 query = mySQLConnection:query ( Query )
  25.                
  26.                 query.onData = function(Q,D) print("Q2") PrintTable(D) end
  27.                
  28.                 query.onSuccess = function()
  29.                     print ( "success" )
  30.                 end
  31.                
  32.                 query:start()
  33.             else
  34.                 print ( "mySQL: No Active Connection!!!" )
  35.             end
  36.         else
  37.             print ( "mySQL: No Query Given!!!" )
  38.         end
  39.     else
  40.         print ( "mySQL: No Active Connection!!!" )
  41.     end
  42. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement