novo Posted December 15, 2011 Share Posted December 15, 2011 Hi all. I wanna set: handler = mysql_connect("127.0.0.1", "****", "******", "n30x") It's for example if i later do: sql = executeSQLSelect it doesn't know to wich database connect. I wanna know how to make mysql_connect for all the code. I don't want to add mysql_connect to all functions. Please help Link to comment
Castillo Posted December 15, 2011 Share Posted December 15, 2011 Do this, create a main resource, example: "mysql", after that connect to MySQL on resource start and make a function like this: function getMySQLConnection() return handler end And in the meta.xml of this resource add this: function="getMySQLConnection" type="server" /> Then you can just use the handler like this: local handler = exports["mysql"]:getMySQLConnection() Link to comment
novo Posted December 15, 2011 Author Share Posted December 15, 2011 So, at the start of the .lua*s i must add: local handler = mysql_connect("127.0.0.1", "****", "******", "n30x") ¿? Plz help <3 and thank you Link to comment
Castillo Posted December 15, 2011 Share Posted December 15, 2011 addEventHandler("onResourceStart",resourceRoot, function () handler = mysql_connect("127.0.0.1", "****", "******", "n30x") if (handler) then outputDebugString("Successfully connected to the MySQL server.") else outputDebugString("Unable to connect to the MySQL server.",1) end end) function getMySQLConnection() return handler end Link to comment
novo Posted December 15, 2011 Author Share Posted December 15, 2011 Wooow ! <3 Thank you !!!!! <3 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now