CodeIgniter Forums
It's possible to connect to a DB but... closing a connection? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: It's possible to connect to a DB but... closing a connection? (/showthread.php?tid=25682)



It's possible to connect to a DB but... closing a connection? - El Forum - 12-20-2009

[eluser]punchi[/eluser]
It's possible?

In PHP, theres a mysql_connect and a mysql_close. Here we connect to a DB (dont know well which function is) but, there's no function to close a connection!!

It's possible (or make the connection null)? How?

Thanks!! =)


It's possible to connect to a DB but... closing a connection? - El Forum - 12-20-2009

[eluser]skunkbad[/eluser]
[quote author="punchi" date="1261381331"]It's possible?

In PHP, theres a mysql_connect and a mysql_close. Here we connect to a DB (dont know well which function is) but, there's no function to close a connection!!

It's possible (or make the connection null)? How?

Thanks!! =)[/quote]
Code:
$this->db->close();



It's possible to connect to a DB but... closing a connection? - El Forum - 12-20-2009

[eluser]punchi[/eluser]
lol... :red:

i don't saw it in the user guide... i though there was all the functions!!, and if there isnt all the functions, there's no API reference? :gulp:!


It's possible to connect to a DB but... closing a connection? - El Forum - 12-21-2009

[eluser]skunkbad[/eluser]
[quote author="punchi" date="1261390937"]lol... :red:

i don't saw it in the user guide... i though there was all the functions!!, and if there isnt all the functions, there's no API reference? :gulp:![/quote]

As far as I know, you are correct. I haven't seen this in the user guide. Unless you are using pconnect, you probably don't need to close the connection. Even w/ pconnect, I'm not sure if you need to close the connection.


It's possible to connect to a DB but... closing a connection? - El Forum - 12-21-2009

[eluser]punchi[/eluser]
If you'r using pconnect, you should close the connection. For a no-pconnect, it's necessary for big querys, because anyway at the end of the script PHP will close connections.

And, is better to have a connection "null" than closing it, at least that appear in discussions in PHP (both ways finish the connection, but closing it can close a TCP layer, giving problems)

So, i'll try the
Code:
$this->db = null;
idea, maybe that line give me an error, but well, I'll try something like that.

Thanks skunkbad! always helping (at least) to me =)