Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require( "mysqloo" )
- local DATABASE_HOST = "localhost"
- local DATABASE_PORT = 3308
- local DATABASE_NAME = "test"
- local DATABASE_USERNAME = "root"
- local DATABASE_PASSWORD = "1234"
- function connectToDatabase()
- local databaseObject = mysqloo.connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME, DATABASE_PORT)
- databaseObject.onConnected = afterConnected
- databaseObject:connect()
- end
- function afterConnected()
- test, isok, error = database:query("SELECT * FROM names");
- if (test) then
- PrintTable(test)
- end
- if (!isok) then
- print(tostring(error) .. "\n");
- end
- test, isok, error = database:query(db, "SELECT 1 + 1");
- if (test) then
- PrintTable(test)
- end
- if (!isok) then
- print(tostring(error) .. "\n");
- end
- test, isok, error = database:query(db, "INSERT INTO names (SteamId,Name) VALUES('fuck me!','it worked')");
- if (test) then
- PrintTable(test)
- end
- if (!isok) then
- print(tostring(error) .. "\n");
- end
- end
Add Comment
Please, Sign In to add comment