Part of the EllisLab Network
   
 
close mysql connection
Posted: 12 November 2008 04:07 AM   [ Ignore ]  
Summer Student
Total Posts:  24
Joined  04-03-2008

Hi,

its posible to close db connection with database , for example at the end of a view write as a mysql_close() or similiar


Many thanks

Profile
 
 
Posted: 12 November 2008 04:46 AM   [ Ignore ]   [ # 1 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2774
Joined  07-27-2006

What are you trying to achieve by closing the connection? You can use the close() method, if you must.

$this->db->close(); 
 Signature 

Check out the Template Library
Oh yeah, I tweet, too (regarding CodeIgniter on occassion).

Profile
 
 
Posted: 12 November 2008 11:47 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
RankRank
Total Posts:  204
Joined  03-12-2007

be careful though.

I was reading on one of the boards here that even if you close the connection, if you try to re-access it, CI will open it again for you.

Obiron

 Signature 

There are 10 kind of people in this world, those who understand binary and those who don’t

Profile
 
 
Posted: 12 November 2008 12:51 PM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  24
Joined  04-03-2008

Ok, just the dude that i’ve , if i call to another controller , i’ll load automaticaly form me.

many thanks

Profile
 
 
Posted: 12 November 2008 04:45 PM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  25
Joined  11-10-2008

CI dosen’t open and close automaticly DB connection at the beginning and at the end of the file?

Profile
 
 
Posted: 12 November 2008 04:49 PM   [ Ignore ]   [ # 5 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2774
Joined  07-27-2006

CI will open a connection right after the Controller is instantiated if the database class is autoloaded, or when the load->database() method is called, or when a model is called and instructed to load the database. CI closes any open connection just before exiting.

 Signature 

Check out the Template Library
Oh yeah, I tweet, too (regarding CodeIgniter on occassion).

Profile