Jump to content

Closing open db connection


Piorun

Recommended Posts

Hi,

I know that in "normal" programming lang i must close db connection. How is it possible to do in MTA (using Lua and db... functions)?

That is wrong. If you need to close the database connection in the middle of the execution of the script, then you can use destroyElement. Otherwise, you can just let Lua's garbage collector close the database connection automatically when it is no longer referenced anywhere in your code (or, for example, when you stop the resource). In other languages, for example, C++, even though you don't have garbage collection, you have idioms like RAII (Resource Acquisition Is Initialization), which take care of that.

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