Part of the EllisLab Network
   
 
close mysql connection
Posted: 12 November 2008 03: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 03:46 AM   [ Ignore ]   [ # 1 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2770
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 10:47 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
RankRank
Total Posts:  202
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 11:51 AM   [ 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 03: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 03:49 PM   [ Ignore ]   [ # 5 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2770
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
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 149816 Total Logged-in Users: 52
Total Topics: 103547 Total Anonymous Users: 5
Total Replies: 517877 Total Guests: 457
Total Posts: 621424    
Members ( View Memberlist )