Close DB connection ??

Permalink 1 user found helpful
Hi,

Maybe my question is stupid. I understood how to establish connection with the database with Loader::db().

But what when my request is finished ? basically, i do a "mysql_close($connect)". but here, with ADODB, i don't know.

Do I have to do something like that ?

thanks

 
bastien31 replied on at Permalink Reply
Hi,

i try this : $db->close();

It doesnt crash... when i read the ADO documentation, it seems to be the right instruction to close a connection.

Anyone can confirm ? thanks
moosh replied on at Permalink Reply
moosh
Hi,

try this :

$db = Loader::db();
$db->Close();
jordanlev replied on at Permalink Best Answer Reply
jordanlev
You shouldn't be closing the database connection in a C5 site -- it may need to be used by other parts of the system or other components later on. They system will close it for you (calling Loader::db() gives you the connection that the system already opened -- since the system opened it, the system is responsible for closing it, not you).
bastien31 replied on at Permalink Reply
thanks jordan. always the good answer :)
i thought there was a mechanism like this one, but wanted a confirmation (rather than let some connections opened but not used)
Mnkras replied on at Permalink Reply
Mnkras
it would be $db->disconnect(); c5 automatically does that though so I would not suggest doing it. (It resets the connection to the default database then disconnects it)

This website stores cookies on your computer. These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media. To find out more about the cookies we use, see our Privacy Policy.