Jump to content

Exporting mysql handler to other resources


theDavid

Recommended Posts

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 by Guest
Link to comment
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...