From 619d18c8f31fd961c82121d921e09fed6c5ac068 Mon Sep 17 00:00:00 2001 From: shish Date: Sat, 28 Jul 2007 14:15:03 +0000 Subject: [PATCH] a somewhat nicer error message for can't connect to DB git-svn-id: file:///home/shish/svn/shimmie2/trunk@390 7f39781d-f577-437e-ae19-be835c7a54ca --- core/database.class.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/core/database.class.php b/core/database.class.php index 9fc69df5..0f249ed6 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -32,10 +32,26 @@ class Database { public function Database() { if(is_readable("config.php")) { require_once "config.php"; - $this->db = NewADOConnection($database_dsn); - $this->db->SetFetchMode(ADODB_FETCH_ASSOC); - $this->db->Execute("SET NAMES utf8"); // FIXME: mysql specific :| - $this->extensions = $this->db->GetAssoc("SELECT name, version FROM extensions"); + $this->db = @NewADOConnection($database_dsn); + if($this->db) { + $this->db->SetFetchMode(ADODB_FETCH_ASSOC); + $this->db->Execute("SET NAMES utf8"); // FIXME: mysql specific :| + $this->extensions = $this->db->GetAssoc("SELECT name, version FROM extensions"); + } + else { + $version = VERSION; + print " + + + Internal error - Shimmie-$version + + + Internal error: Could not connect to database + + + "; + exit; + } } else { header("Location: install.php");