Jump to content

[Help] SQL


XML

Recommended Posts

Posted

Hello, I got this weird problem, [Expected db-connection at argument 1]

The script was working fine for a long time, but suddenly this error appeared.

So when i get this error, I restart the resource, And then it works, And the same problem appears again after a while.

Did someone got the same problem before ?

 

Help.

 

Posted

The connection could have timed out. If there is no query for some time period (usually around 20-30 minutes) then the (My)SQL server closes the connection.

Posted

So i have to put an (if) statement ?

To check whether is there a connection or not ?

And if not, I make a new connection ?

Posted

Yes, or if you do a lot of queries, then make your own query function and stick the condition in there so you don't have to repeat the same thing everywhere.

Posted (edited)

I suppose you use dbQuery, so:

_dbQuery = dbQuery --store the original func
function dbQuery (connection, ...)
  local arg = {...}
  if not connection then
    connectionGlobal = dbConnect() --fill it in and change connectionGlobal to wherever you store the connection
    connection = connectionGlobal
  end
  _dbQuery(connection, unpack(arg))
end

Note that this won't work if you use callbacks in dbQuery as it expects the first argument to be the connection.

Also, didn't test this.

Edited by MIKI785
Forgot to use the original func..
  • Thanks 1

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