Skip to content

Commit 32593f9

Browse files
committed
Merge pull request bcit-ci#1378 from gintsmurans/develop
Move closing of database connection to CI_DB_driver->__destruct - bcit-ci#1376
2 parents 1d79efe + 89f77ee commit 32593f9

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

system/core/CodeIgniter.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -393,15 +393,5 @@ function &get_instance()
393393
*/
394394
$EXT->call_hook('post_system');
395395

396-
/*
397-
* ------------------------------------------------------
398-
* Close the DB connection if one exists
399-
* ------------------------------------------------------
400-
*/
401-
if (class_exists('CI_DB') && isset($CI->db) && ! $CI->db->pconnect)
402-
{
403-
$CI->db->close();
404-
}
405-
406396
/* End of file CodeIgniter.php */
407397
/* Location: ./system/core/CodeIgniter.php */

system/database/DB_driver.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,6 +1390,23 @@ protected function _reset_select()
13901390
{
13911391
}
13921392

1393+
// --------------------------------------------------------------------
1394+
1395+
/**
1396+
* Destructor
1397+
*
1398+
* Closes the database connection, if needed.
1399+
*
1400+
* @return void
1401+
*/
1402+
public function __destruct()
1403+
{
1404+
if ($this->conn_id && ! $this->pconnect)
1405+
{
1406+
$this->close();
1407+
}
1408+
}
1409+
13931410
}
13941411

13951412
/* End of file DB_driver.php */

0 commit comments

Comments
 (0)