Permalink
Browse files

Merge pull request #1378 from gintsmurans/develop

Move closing of database connection to CI_DB_driver->__destruct - #1376
  • Loading branch information...
narfbg committed May 22, 2012
2 parents 1d79efe + 89f77ee commit 32593f9aa821a80f5e9fc2dbbae0b4f5f1078dd8
Showing with 17 additions and 10 deletions.
  1. +0 −10 system/core/CodeIgniter.php
  2. +17 −0 system/database/DB_driver.php
@@ -393,15 +393,5 @@ function &get_instance()
*/
$EXT->call_hook('post_system');
-/*
- * ------------------------------------------------------
- * Close the DB connection if one exists
- * ------------------------------------------------------
- */
- if (class_exists('CI_DB') && isset($CI->db) && ! $CI->db->pconnect)
- {
- $CI->db->close();
- }
-
/* End of file CodeIgniter.php */
/* Location: ./system/core/CodeIgniter.php */
@@ -1390,6 +1390,23 @@ protected function _reset_select()
{
}
+ // --------------------------------------------------------------------
+
+ /**
+ * Destructor
+ *
+ * Closes the database connection, if needed.
+ *
+ * @return void
+ */
+ public function __destruct()
+ {
+ if ($this->conn_id && ! $this->pconnect)
+ {
+ $this->close();
+ }
+ }
+
}
/* End of file DB_driver.php */

0 comments on commit 32593f9

Please sign in to comment.