diff options
author | Paul Arthur <flowerysong00@yahoo.com> | 2012-11-08 13:15:19 -0500 |
---|---|---|
committer | Paul Arthur <flowerysong00@yahoo.com> | 2012-11-08 13:15:19 -0500 |
commit | d2eaf10b072f8cb1dca887af2006eba00a3fc0fa (patch) | |
tree | c66320acdac0981575825de02608b867b65fdb7f | |
parent | 0d78b77443481e3678d933c9590a4e2f7a4f90fa (diff) | |
download | ampache-d2eaf10b072f8cb1dca887af2006eba00a3fc0fa.tar.gz ampache-d2eaf10b072f8cb1dca887af2006eba00a3fc0fa.tar.bz2 ampache-d2eaf10b072f8cb1dca887af2006eba00a3fc0fa.zip |
Move check_database into the Dba class
-rw-r--r-- | lib/class/dba.class.php | 20 | ||||
-rw-r--r-- | lib/debug.lib.php | 25 | ||||
-rw-r--r-- | lib/install.lib.php | 2 | ||||
-rw-r--r-- | templates/show_test.inc.php | 2 |
4 files changed, 22 insertions, 27 deletions
diff --git a/lib/class/dba.class.php b/lib/class/dba.class.php index 75735819..03bf441c 100644 --- a/lib/class/dba.class.php +++ b/lib/class/dba.class.php @@ -277,6 +277,26 @@ class Dba { } // _connect /** + * check_database + * + * Make sure that we can connect to the database + */ + public static function check_database($host,$username,$pass) { + + $dbh = @mysql_connect($host, $username, $pass); + + if (!is_resource($dbh)) { + return false; + } + if (!$host || !$username) { + return false; + } + + return $dbh; + + } // check_database + + /** * show_profile * This function is used for debug, helps with profiling */ diff --git a/lib/debug.lib.php b/lib/debug.lib.php index 4c8b0ec0..9b8b8e05 100644 --- a/lib/debug.lib.php +++ b/lib/debug.lib.php @@ -31,31 +31,6 @@ */ /** - * check_database - * - * checks the local mysql db and make sure life is good - * - * @param string $host Hostname - * @param string $username Username - * @param string $pass Password - * @return mixed false or Database resource - */ -function check_database($host,$username,$pass) { - - $dbh = @mysql_connect($host, $username, $pass); - - if (!is_resource($dbh)) { - return false; - } - if (!$host || !$username) { - return false; - } - - return $dbh; - -} // check_database - -/** * check_database_inserted * checks to make sure that you have inserted the database * and that the user you are using has access to it diff --git a/lib/install.lib.php b/lib/install.lib.php index 28368a4e..59266bca 100644 --- a/lib/install.lib.php +++ b/lib/install.lib.php @@ -83,7 +83,7 @@ function install_check_status($configfile) { if they don't then they're cool */ $results = parse_ini_file($configfile); - $dbh = check_database($results['database_hostname'],$results['database_username'],$results['database_password']); + $dbh = Dba::check_database($results['database_hostname'],$results['database_username'],$results['database_password']); if (!is_resource($dbh)) { Error::add('general', T_('Unable to connect to database, check your ampache config')); diff --git a/templates/show_test.inc.php b/templates/show_test.inc.php index 3a8372ff..1094f52f 100644 --- a/templates/show_test.inc.php +++ b/templates/show_test.inc.php @@ -194,7 +194,7 @@ <td valign="top"><?php echo T_("Database connection"); ?></td> <td valign="top">[ <?php - $db = check_database($results['database_hostname'], $results['database_username'], $results['database_password'],$results['database_name']); + $db = Dba::check_database($results['database_hostname'], $results['database_username'], $results['database_password'],$results['database_name']); if (!$db) { echo debug_result('',false); } |