DriFtyZ Posted June 6, 2017 Share Posted June 6, 2017 Hello there, i want to export some database functions instead of using db connect on all resources, how can i make it? Link to comment
Dimos7 Posted June 6, 2017 Share Posted June 6, 2017 you can export you function throught your meta <export function="name of function here" type="server"/> Link to comment
Hale Posted June 6, 2017 Share Posted June 6, 2017 (edited) Initialize a connection inside "MySQL" resource, and then make exported functions that once called upon, will use the initialized connection. For example: mySQL = dbConnect( "mysql", "dbname=mta;host=localhost", "myserver", "12345") function query(str) if mySQL then local query = dbQuery(mySQL, str) if not ( query ) then return false end local result, num_rows, id = dbPoll(query, -1) return result or false, num_rows or false, id or false end return false end And then in meta.xml simply include: <export function="query" type="server"/> Edited June 6, 2017 by Hale 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