version 1.7, 2000/10/23 01:00:20
|
version 1.18, 2005/07/05 21:27:12
|
Line 37 sub CheckTable
|
Line 37 sub CheckTable
|
my ($TabName) = @_; |
my ($TabName) = @_; |
my ($ans); |
my ($ans); |
|
|
if (scalar(grep(/^$TabName$/, @tbl_list))) { |
if (scalar(grep(/^$TabName$/i, @tbl_list))) { |
print "Table $TabName exists. Do you want to delete it? "; |
print "Table $TabName exists. Do you want to delete it? "; |
$ans = <STDIN>; |
$ans = <STDIN>; |
if ($ans =~ /[yY]/) { |
if ($ans =~ /[yY]/) { |
Line 57 print "Before connecting to the DB\n";
|
Line 57 print "Before connecting to the DB\n";
|
or die "Can't connect to DB chgk\n" . $dbh->errstr; |
or die "Can't connect to DB chgk\n" . $dbh->errstr; |
print "Connected successfully\n"; |
print "Connected successfully\n"; |
|
|
@tbl_list = $dbh->func( '_ListTables' ); |
@tbl_list = $dbh->tables(); |
|
|
&CheckTable("Questions"); |
&CheckTable("Questions"); |
$dbh->do("CREATE TABLE Questions ( |
$dbh->do("CREATE TABLE Questions ( |
Line 65 print "Connected successfully\n";
|
Line 65 print "Connected successfully\n";
|
KEY QuestionIdKey (QuestionId), |
KEY QuestionIdKey (QuestionId), |
ParentId SMALLINT UNSIGNED NOT NULL, |
ParentId SMALLINT UNSIGNED NOT NULL, |
KEY ParentIdKey (ParentId), |
KEY ParentIdKey (ParentId), |
Number TINYINT UNSIGNED NOT NULL, |
Number SMALLINT UNSIGNED NOT NULL, |
KEY NumberKey (Number), |
KEY NumberKey (Number), |
Type TEXT NOT NULL, |
Type CHAR(5) NOT NULL DEFAULT 'þ', |
|
KEY TypeKey (Type), |
Question TEXT, |
Question TEXT, |
Answer TEXT, |
Answer TEXT, |
|
PassCriteria TEXT, |
Authors TEXT, |
Authors TEXT, |
Sources TEXT, |
Sources TEXT, |
Comments TEXT, |
Comments TEXT, |
Rating TEXT |
Rating TEXT, |
)") |
Topic TEXT, |
|
ProcessedBySearch INT |
|
) TYPE=MyISAM") |
or die "Can't create Questions table: $!\n"; |
or die "Can't create Questions table: $!\n"; |
|
|
&CheckTable("Tournaments"); |
&CheckTable("Tournaments"); |
Line 85 print "Connected successfully\n";
|
Line 89 print "Connected successfully\n";
|
ParentId INT UNSIGNED NOT NULL, |
ParentId INT UNSIGNED NOT NULL, |
KEY ParentIdKey (ParentId), |
KEY ParentIdKey (ParentId), |
Title TINYTEXT NOT NULL, |
Title TINYTEXT NOT NULL, |
|
Number SMALLINT UNSIGNED, |
QuestionsNum INT UNSIGNED DEFAULT 0, |
QuestionsNum INT UNSIGNED DEFAULT 0, |
Type ENUM('ç','ô','þ'), |
Type ENUM('ç','ô','þ'), |
Copyright TEXT, |
Copyright TEXT, |
Line 95 print "Connected successfully\n";
|
Line 100 print "Connected successfully\n";
|
EnteredBy TEXT, |
EnteredBy TEXT, |
PlayedAt DATE, |
PlayedAt DATE, |
CreatedAt DATE NOT NULL |
CreatedAt DATE NOT NULL |
)") |
) TYPE=MyISAM") |
or die "Can't create Tournaments table: $!\n"; |
or die "Can't create Tournaments table: $!\n"; |
|
|
# CREATE INDEX ParentInd ON Tournaments (ParentId) |
# CREATE INDEX ParentInd ON Tournaments (ParentId) |