Jump to content

Closing open db connection


Piorun

Recommended Posts

Posted

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)?

Posted

Use

destroyElement 

to close DB connection.

Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS.

Developer and owner of

https://projectbea.st - Project Beast
Posted
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.

I used to know how to code, but then I took an arrow in the knee.

Project Redivivus - Remaking Old School MTA With New Code

MTA 0.6 Nightly 1 released

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