sql.Query("CREATE TABLE IF NOT EXISTS [prefered-model] ( [UniqueID] INTEGER NOT NULL PRIMARY KEY, [Model] TEXT DEFAULT \'"..defaultmodel.."\' NOT NULL );" --this will create the table so that we can store shit local meta = FindMetaTable("Player") function meta:StoreModel( model ) local uid = self:UniqueID() local model = sql.SQLStr( model ) -- sql.SQLStr makes a string safe to be put into a database(escapes backslashes mostly) local q = sql.QueryValue( "SELECT [Model] FROM [prefered-model] WHERE [UniqueID] = "..uid.." LIMIT 1;" ) --This is how we will test if the player has already been submitted before if q then sql.Query("UPDATE [prefered-model] SET [Model] = \'" .. model .. "\' WHERE [UniqueID] = " .. uid .. " LIMIT 1;" ) -- The player has been submitted before, we are jsut updating them else sql.Query("INSERT INTO [prefered-model] ( [UniqueID], [Model] ) VALUES ( "..uid..", \'"..model.."\' );") -- Here we insert into the database end end function meta:GetPrefModel( ) model = sql.QueryValue("SELECT [Model] FROM [prefered-model] WHERE [UniqueID] = "..self:UniqueID().." LIMIT 1;" ) return model end