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
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
Hi,
try this :
$db = Loader::db();
$db->Close();
try this :
$db = Loader::db();
$db->Close();
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).
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)
i thought there was a mechanism like this one, but wanted a confirmation (rather than let some connections opened but not used)
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)
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