Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(not fs.exists("json")) then
- print("Whoah there! This utility will not work correctly without the json decoding API by ElvishJerricco!")
- return
- end
- os.loadAPI("json")
- function query(host,username,password,dbname,query)
- ping = http.post(
- "http://budgieblue.net23.net/query.php",
- "host="..host.."&username="..username.."&password="..password.."&dbname="..dbname.."&query="..query
- )
- response = ping.readAll()
- ping.close()
- return json.decode( response )
- end --Returns the rows of your query
- --EXAMPLE:
- --[[
- SELECT * FROM users WHERE username="user"
- If you have a database setup like that,
- it would return all the rows in the entry
- that has a matching username, as variables.
- Basically if a password was in a column named
- password,it would return
- {password="whatever it was"}.
- So you can access it by [query].password.
- Overcomplicated (in my opinion) ;P
- --]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement