Posted by Anonymous on Sat 18 Jul 01:54 (modification of post by
- db, error = mysql.connect("[CENSORED]servers.co.uk","killerss_youarem","aBiGJbuelZnKQxP87AUWYlBj9AG6in","killerss_you")
- local host = "[CENSORED]servers.co.uk"
- local username = "killerss_youarem"
- local password = "aBiGJbuelZnKQxP87AUWYlBj9AG6in"
- local database = "killerss_you"
- local port = 3306
- local persistant = true
- require( "mysql" )
- local db
- fucntion DoQuery(query, type)
- local result, isok, err = mysql.query(db, query, type or mysql.QUERY_NUMERIC)
- if not isok and err == "" then isok = true end -- false positive
- if not isok then
- Error(tostring(err))
- return nil
- end
- return result
- end
- function Connect()
- if db then return db end -- Still connected
- db, err = mysql.connect(host, username, password, database, port)
- if db == 0 then
- Error(tostring(err))
- db = nil
- return
- end
- return db
- end
- function Disconnect(force)
- if not db then return end -- Already disconnected
- if persistent and not force then return end -- Don't disconnect persistent
- local succ, err = mysql.disconnect(db)
- if not succ then
- error(tostring(err))
- end
- db = nil
- end
- hook.Add("ShutDown", "SQLDisconnect", function() disconnect(true) end) -- Force closed on shutdown
Follow on Twitter!