Jump to content

SOLVED Return mysql result


uBiT

Recommended Posts

Hello,

how can i use mysql_query function in other resource?

I created export function executeQuery():

function executeQuery(query) 
    if query then 
        allQueries = allQueries + 1 
        local result = mysql_query(dbHandler, query) 
        if not result then 
            sendSQLLog('>>> MySQL ERROR: ('..mysql_errno(dbHandler)..') '..mysql_error(dbHandler)) 
            return false 
        else 
            return result 
        end 
    end 
end 

In local resource(where function is) it returns valid mysql result, but if i use in other resource ex.:

local checkLogin = exports['mysql']:executeQuery('SELECT ID FROM accounts WHERE Username = \''..username..'\' AND Password = \''..password..'\' LIMIT 1') 

it returns only executed string, not mysql result.

Edited by Guest
Link to comment

So, if mysql_query success, it returns result and if not - returns false. I known that.

I need, to use mysql functions in other resources without connecting to mysql server in each resource.

So, with my created function: executeQuery() it returns only string, but not result.

EDIT:

Nevermind, solved storing mysql results in table and return saved result id.

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...