theDavid Posted July 29, 2013 Share Posted July 29, 2013 (edited) Hi there, is it possible to export a mysql handler to other resources so it can be used for mysql_query function? I tried to do that bit of code but it does not work out for me: mysql resource lua file: function start() mysql = mysql_connect("localhost", "root", "", "mta") if mysql then return mysql end end mysql meta file: <script src="mysql.lua" type="server" /> <export function="start" type="server" /> and I use it in other resources like this: handler = exports["mysql"]:start() and this does not work. Edited July 29, 2013 by Guest Link to comment
Wei Posted July 29, 2013 Share Posted July 29, 2013 function="query" type="server" /> Why do you export query if your function name is start? Link to comment
theDavid Posted July 29, 2013 Author Share Posted July 29, 2013 function="query" type="server" /> Why do you export query if your function name is start? Ops, wrong line but it still does not work. it returns a nil value. Link to comment
Castillo Posted July 29, 2013 Share Posted July 29, 2013 function start ( ) mysql = mysql_connect ( "localhost", "root", "", "mta" ) end addEventHandler ( "onResourceStart", resourceRoot, start ) function getMySQLHandler ( ) return mysql end On meta: function="getMySQLHandler" type="server" /> P.S: May I ask why are you using this mysql module and not the built-in MTA MySQL functions which are easier to use and better? 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