From 5ced82ab986f6a53ca95f5498a63ac503ea8f580 Mon Sep 17 00:00:00 2001 From: "Halmai, Csongor" Date: Mon, 7 Dec 2015 13:20:39 +1100 Subject: Detecting if database connection was not successful --- system/core/Loader.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'system') diff --git a/system/core/Loader.php b/system/core/Loader.php index 18e4c5287..7593ae5d6 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -361,6 +361,10 @@ class CI_Loader { // Load the DB class $CI->db =& DB($params, $query_builder); + if (!$CI->db->conn_id) + { + return FALSE; + } return $this; } -- cgit v1.2.3-24-g4f1b From 0f56007d95a8713f0c4276e37604e221f4efbe66 Mon Sep 17 00:00:00 2001 From: "Halmai, Csongor" Date: Tue, 8 Dec 2015 11:32:35 +1100 Subject: rolling back previous solution; throwing exception if database connection was not successful. --- system/core/Loader.php | 4 ---- system/database/DB_driver.php | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) (limited to 'system') diff --git a/system/core/Loader.php b/system/core/Loader.php index 7593ae5d6..18e4c5287 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -361,10 +361,6 @@ class CI_Loader { // Load the DB class $CI->db =& DB($params, $query_builder); - if (!$CI->db->conn_id) - { - return FALSE; - } return $this; } diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 25e70ec3f..fb9955b7c 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -436,7 +436,7 @@ abstract class CI_DB_driver { $this->display_error('db_unable_to_connect'); } - return FALSE; + throw new RuntimeException('Database connection failure.'); } } -- cgit v1.2.3-24-g4f1b