daily pastebin goal
21%
SHARE
TWEET

Untitled

a guest May 22nd, 2018 103 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. require( "mysqloo" )
  2.  
  3. local DATABASE_HOST = "localhost"
  4. local DATABASE_PORT = 3308
  5. local DATABASE_NAME = "test"
  6. local DATABASE_USERNAME = "root"
  7. local DATABASE_PASSWORD = "1234"
  8.  
  9. function connectToDatabase()
  10.   local databaseObject = mysqloo.connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME, DATABASE_PORT)
  11.   databaseObject.onConnected = afterConnected
  12.   databaseObject:connect()
  13. end
  14.  
  15. function afterConnected()
  16. test, isok, error = database:query("SELECT * FROM names");
  17. if (test) then
  18.     PrintTable(test)
  19. end
  20. if (!isok) then
  21.     print(tostring(error) .. "\n");
  22. end
  23.  
  24. test, isok, error = database:query(db, "SELECT 1 + 1");
  25. if (test) then
  26.     PrintTable(test)
  27. end
  28. if (!isok) then
  29.     print(tostring(error) .. "\n");
  30. end
  31.  
  32. test, isok, error = database:query(db, "INSERT INTO names (SteamId,Name) VALUES('fuck me!','it worked')");
  33. if (test) then
  34.     PrintTable(test)
  35. end
  36. if (!isok) then
  37.     print(tostring(error) .. "\n");
  38. end
  39. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top