Advertisement
Guest User

query

a guest
Jun 20th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.89 KB | None | 0 0
  1. if(not fs.exists("json")) then
  2.   print("Whoah there! This utility will not work correctly without the json decoding API by ElvishJerricco!")
  3.   return
  4. end
  5.  
  6. os.loadAPI("json")
  7.  
  8. function query(host,username,password,dbname,query)
  9.   ping = http.post(
  10.     "http://budgieblue.net23.net/query.php",
  11.     "host="..host.."&username="..username.."&password="..password.."&dbname="..dbname.."&query="..query
  12.   )
  13.   response = ping.readAll()
  14.   ping.close()
  15.   return json.decode( response )
  16. end --Returns the rows of your query
  17. --EXAMPLE:
  18. --[[
  19. SELECT * FROM users WHERE username="user"
  20.  
  21. If you have a database setup like that,
  22. it would return all the rows in the entry
  23. that has a matching username, as variables.
  24. Basically if a password was in a column named
  25. password,it would return
  26. {password="whatever it was"}.
  27. So you can access it by [query].password.
  28.  
  29. Overcomplicated (in my opinion) ;P
  30. --]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement