From 09dfe32eb6b538225686fd6ed0220240010bc574 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 1 Aug 2011 01:22:36 -0400 Subject: initial commit. Partway through a rewrite. I have some old files I didn't want to entirely delete. --- installer/include.php | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 installer/include.php (limited to 'installer/include.php') diff --git a/installer/include.php b/installer/include.php new file mode 100644 index 0000000..7300e90 --- /dev/null +++ b/installer/include.php @@ -0,0 +1,81 @@ +Database . ''; + } + $r.=$t->inputP("Existing databases: ".implode(', ',$db_array)); + + if (!in_array($db_name, $db_array)) { + $str.=$t->inputP("Creating database $db_name..."); + $db = mysql_query("CREATE DATABASE $db_name;", $mysql); + if ($db===FALSE) { + $str.=$t->inputP("Database $db_name ". + "could not be created: ". + mysql_error($mysql), true); + return false; + } + } + $r.=$t->inputP("Selecting database $db_name..."); + $db = mysql_select_db($db_name, $mysql); + if (!$db) { + $r.=$t->inputP('Could not select database: ', + mysql_error($mysql), true); + return false; + } + return true; + } else { + return false; + } +} + +function mm_mysql_count_rows_in_table($mysql, $table_name) { + $table=mysql_real_escape_string($table_name); + $query = + "SELECT COUNT(*)\n". + "FROM $table;"; + $total = mysql_query($query, $mysql); + $total = mysql_fetch_array($total); + $total = $total[0]; + return $total; +} + +function mm_mysql_table_exists($mysql, $table_name) { + $table=mysql_real_escape_string($table_name); + $query = + "SELECT COUNT(*)\n". + "FROM information_schema.tables\n". + "WHERE table_name = '$table';"; + $total = mysql_query($query, $mysql); + $total = mysql_fetch_array($total); + $total = $total[0]; + return $total>0; +} -- cgit v1.2.3-54-g00ecf