MySQL Tables

Could someone show me how to create tables with mysqloo, I can’t seem to figure it out for some reason. I remember doing it sometime before, but its been a very long time.

[lua]
require(“mysqloo”)
database = mysqloo.connect(Host, User, Pass, DB, Port)
database.onConnected = function()
print(“Successfully to connected to database.”)
end
database.onConnectionFailed = function()
print(“Failed to connect to the database.”)
end
database:connect()
timer.Simple(1, function()
local query1 = database:query( "CREATE TABLE IF NOT EXISTS " … Prefix … “_link (id INTEGER NOT NULL, steamid TEXT NOT NULL)”)
query1.onSuccess = function( query, data )
end
query1:start()
end)
[/lua]

much appreciated!

Shit, one last question. How do I pull the information out of a table? I’ve tried and only been able to get it to print a table, but not just the value within the table. With database:query(“SELECT something FROM table WHERE something = something”)

Try this.

[lua]
function ResetUser(self)
if !self then return end
if !Reset then return end
local query1 = database:query("SELECT id FROM " … Prefix … “_link WHERE steamid=’” … self:SteamID() … “’”)
query1.onError = function( err, sql )
MsgN( “Query1 errored!” )
MsgN( “Query:”, sql )
MsgN( “Error:”, err )
end
query1.onSuccess = function( query, data )
local Arg = query:getData()[1] or nil
if Arg && Arg[‘id’] then
local query2 = database:query("DELETE FROM " … Prefix … “_link WHERE steamid=’” … self:SteamID() … “’”)
query2.onError = function( err, sql )
MsgN( “Query2 errored!” )
MsgN( “Query:”, sql )
MsgN( “Error:”, err )
end
query2.onSuccess = function( query, data )
self.Registered = false
umsg.Start(“cl_register”, self)
umsg.End()
umsg.Start(“cl_error”, self)
umsg.String(“Attention;You’ve unlink your account via reset.”)
umsg.End()
self:ChatPrint(“Your account has been succesfully unlinked.”)
end
query2:start()
end
end
query1:start()
end
[/lua]

If you wanna see mysqloo being used examine/copy some of my code here.