Jump to content

call()


izstas

Recommended Posts

I call function:

local result = call(getResourceFromName("db"), "sql_query", "SELECT ....'"); 

function sql_query work when I call it from resource "db", when I call it from other resource - it returns "SELECT ....". Why? Function sql_query is exported.

Log:

[15:54:03] ERROR: [script path has been here] : bad argument #1 to 'mysql_fetch_assoc' (LuaBook.mysqlResult expected, got string) 
[15:54:03] ERROR: call: Check the function exists, is exported and you've passed the correct arguments 

Link to comment
function sql_query(arg) 
    return db.sql_query(arg); 
end; 

:D

function db.sql_query(query, hideinlist) 
    if (db.connected == false) then 
        outputServerLog("SQL ERROR: [Error message has been here]"); 
        return; 
    end; 
    queryres = mysql_query(db.connection, query); 
    db.num_quries = db.num_quries + 1; 
    if (hideinlist == nil) then 
        db.quries[db.num_quries] = {["query"] = query}; 
    else 
        db.quries[db.num_quries] = {["query"] = "HIDDEN"}; 
    end; 
    if (not queryres) then 
        outputServerLog("SQL ERROR: \n ".. query .." \n\n #" .. db.sql_errno() .. ": " .. db.sql_error()); 
    end; 
    return queryres; 
end; 

Link to comment

Why do you use mysql_query in sql query?

Also, how do you expect result from query to be a string?

The result from a SQL query is stored in a result-set. Most database software systems allow navigation of the result set with programming functions, like: Move-To-First-Record, Get-Record-Content, Move-To-Next-Record, etc.
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...