Welcome Guest, Not a member yet? Register   Sign In
Close Mysql connection
#1

[eluser]Nathan Payne[/eluser]
hey!

I am developing a site at the moment and relies alot on DB interactions, I am looking for a way to close the connections that are made.

I tried setting:

$db['default']['pconnect'] = FALSE;

But instead of closing the connection it keeps it open and just opens a new connection for further queries.

I would prefer to auto close connections on every page load to free up as many as possible.

I dont want to go through every query that I have just to do a close connection so I am willing to extend libraries if required.

Does anyone have a solution, or can you point me in the correct direction?
#2

[eluser]InsiteFX[/eluser]
Not tested but give this a try!
You will need to get a reference to the CodeIgniter Super Object...
Code:
/*
* ------------------------------------------------------
*  Close the DB connection if one exists
* ------------------------------------------------------
*/
if (class_exists('CI_DB') AND isset($CI->db))
{
    $CI->db->close();
}

InsiteFX
#3

[eluser]danmontgomery[/eluser]
http://php.net/manual/en/function.mysql-connect.php

Quote:Note:

The link to the server will be closed as soon as the execution of the script ends, unless it's closed earlier by explicitly calling mysql_close().




Theme © iAndrew 2016 - Forum software by © MyBB