From ce395e6b57ae4e14ec016785cffbd4b7b0880b2f Mon Sep 17 00:00:00 2001
From: Jason Cleeland
Date: Thu, 26 Jun 2003 13:39:30 +0000
Subject: [PATCH] Added facility to check that the appropriate tables also
exist.
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/trunk/unstable@400 b72ed6b6-b9f8-46b5-92b4-906544132732
---
admin/checkfields.php | 37 +++++++++++++++++++++++++++++++++++--
1 file changed, 35 insertions(+), 2 deletions(-)
diff --git a/admin/checkfields.php b/admin/checkfields.php
index 48ade700748..73c2d114c71 100644
--- a/admin/checkfields.php
+++ b/admin/checkfields.php
@@ -1,6 +1,11 @@
Checking $databasename to ensure all tables exist
\n";
-include("config.php");
+$result = mysql_list_tables($databasename);
+while ($row = mysql_fetch_row($result))
+ {
+ $tablelist[]=$row[0];
+ }
+foreach ($alltables as $at)
+ {
+ echo "--== Checking $at ==--
";
+ if (!in_array($at, $tablelist))
+ {
+ echo "$at table does not exist!
\n";
+ //Create table
+ $ctquery="CREATE TABLE `$at` (\n";
+ foreach ($allfields as $af)
+ {
+ if ($af[0] == $at)
+ {
+ $ctquery .= $af[2]."\n";
+ }
+ }
+ $ctquery .= ")\n";
+ $ctquery .= "TYPE=MyISAM";
+ $ctresult=mysql_query($ctquery) or die ("Couldn't create $at table
$ctquery
".mysql_error);
+ echo "Table Created!";
+ }
+ echo "
\n";
+ }
+echo "
\n";
-echo "$setfontChecking $databasename to ensure all fields exist\n";
+echo "$setfontChecking $databasename to ensure all fields exist\n";
//GET LIST OF TABLES
$tables = mysql_list_tables($databasename);