Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # simplified handler for database access
- module Database
- # url the post is being made to
- @@url = "your web url that hosts the PHP script"
- # simple function to group posting to the actual URL
- def self.makeRequest(type, data = {})
- data["type"] = type
- return pbPostData(@@url,data)
- end
- # function used to add row to specific table
- def self.addTestSubject(name, surname, age)
- data = {
- "name" => name,
- "surname" => surname,
- "age" => age
- }
- self.makeRequest("addTestSubject",data)
- end
- end
- # this writes data to table
- Database.addTestSubject("Tim","Timmons",20)
- # this reads the data from the table
- req = Database.makeRequest("getTestSubjects").split("\r\n")
- lines = []
- # this splits the data up into an array to make it more usable
- for r in req
- lines.push(r.split("</s>"))
- end
- # this prints out the result
- p lines
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement