Welcome Guest, Not a member yet? Register   Sign In
How do I close a database connection?
#1

[eluser]uris[/eluser]
Does CI have any function to close a database connection? I want to be able to close every connection I make manually, but I have not been able to find the CI native function to do this.
#2

[eluser]Michael Wales[/eluser]
Why would you want to do that?

Regardless, you can just turn off pconnect in database.php and the connection will be closed at the end of each script's execution.
#3

[eluser]blackarma[/eluser]
uris is right, in some case mysql connection are not closed automatically even with mysql_connect (due to some bad script ending).

The method close() exists (line 1020 od the DB_drivers.php file, @access public) but not documented, so to close your database connection just use : $this->db->close();
#4

[eluser]Grind[/eluser]
[quote author="blackarma" date="1191438925"]uris is right, in some case mysql connection are not closed automatically even with mysql_connect (due to some bad script ending).

The method close() exists (line 1020 od the DB_drivers.php file, @access public) but not documented, so to close your database connection just use : $this->db->close();[/quote]
Does this still apply to the current version of Codeigniter?




Theme © iAndrew 2016 - Forum software by © MyBB