Jump to content
  • 0

MySQL Multi Query?


sanyisasha

Question

Hello. I want to create a function, what save all to my database.

That's easy. But i want to use the "multi query".

An example:

"UPDATE table SET ... WHERE ...; UPDATE table SET ...2 WHERE ...2 [...]

My problem: The MTA always say: Syntax error. Like if i use the old php mysql, with query | multi_query.

So: It's posible to use mysql in multiquery?

So sorry for worst english :(

Link to comment

3 answers to this question

Recommended Posts

  • 0

Eh :/

But the simple query is too lagy with much data :/

for i,v in ipairs(vehs) do

dbExec(DB,"UPDATE vehs SET x='"..x.."',y='"..y.."',z='"..z.."',rotx='"..rotx.."',roty='"..roty.."',rotz='"..rotz.."' WHERE id='"..v["id"].."'")

end

End i want to use like:

for i,v in ipairs(vehs) do

sql = sql.."UPDATE vehs SET x='"..x.."',y='"..y.."',z='"..z.."',rotx='"..rotx.."',roty='"..roty.."',rotz='"..rotz.."' WHERE id='"..v["id"]..'";"

end

dbExec(sql)

Link to comment
  • 0

It may help, do not use it when you're saving something that comes from an input or whatever a player can edit

  
_dbExec = dbExec 
  
function dbExec(db, query) 
    local query = split(query, ";") or query 
    if ( type(query) == "table" ) then 
        for _, q in ipairs(query) do 
            _dbExec(db, q) 
        end 
    else 
        _dbExec(db, query) 
    end 
end 
  

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