version 1.1, 2001/05/18 01:37:51
|
version 1.6, 2001/05/18 03:23:44
|
Line 1
|
Line 1
|
package dbchgk; |
package dbchgk; |
use DBI; |
use DBI; |
use Exporter; |
use Exporter; |
use VARS qw(@ISA @EXPORT); |
use locale; |
|
use vars qw(@ISA @EXPORT); |
@ISA=qw(Exporter); |
@ISA=qw(Exporter); |
|
|
@EXPORT = qw(&getbase &closebase &getrow $z &in2out &getall &out2in &mydo |
@EXPORT = qw(&getbase &closebase &getrow $z &in2out &getall &out2in &mydo |
Line 10 use VARS qw(@ISA @EXPORT);
|
Line 11 use VARS qw(@ISA @EXPORT);
|
my $z; |
my $z; |
my $qbase; |
my $qbase; |
BEGIN {do "chgk.cnf"; |
BEGIN {do "chgk.cnf"; |
$qbase = DBI -> connect ("DBI:mysql:$base",undef,undef); |
$qbase = DBI -> connect ("DBI:mysql:$base",'piataev',''); |
}; |
}; |
|
|
|
|
Line 18 BEGIN {do "chgk.cnf";
|
Line 19 BEGIN {do "chgk.cnf";
|
sub getbase |
sub getbase |
{ |
{ |
my $a=join(", ",@_); |
my $a=join(", ",@_); |
$z= $qbase -> prepare("select $a FROM questions WHERE QuestionId<=$qnumber"); |
$z= $qbase -> prepare("select $a FROM Questions WHERE QuestionId<=$qnumber"); |
$z -> execute; |
$z -> execute; |
} |
} |
|
|
Line 26 sub getbase
|
Line 27 sub getbase
|
sub getquestion |
sub getquestion |
{ |
{ |
my $a=shift; |
my $a=shift; |
$z= $qbase -> prepare("select Question, Answer, Comments FROM questions WHERE QuestionId=$a"); |
$z= $qbase -> prepare("select Question, Answer, Comments FROM Questions WHERE QuestionId=$a"); |
$z -> execute; |
$z -> execute; |
$z -> fetchrow; |
$z -> fetchrow; |
} |
} |
Line 73 sub in2out
|
Line 74 sub in2out
|
|
|
|
|
$z= $qbase -> prepare ( "select t2.Id, t2.Number, t3.FileName |
$z= $qbase -> prepare ( "select t2.Id, t2.Number, t3.FileName |
from questions AS t1, tournaments AS t2 , tournaments AS t3 |
from Questions AS t1, Tournaments AS t2 , Tournaments AS t3 |
where (t1.QuestionId = $qid) && (t1.ParentId = t2.Id) && (t2.ParentId = t3.Id) "); |
where (t1.QuestionId = $qid) && (t1.ParentId = t2.Id) && (t2.ParentId = t3.Id) "); |
|
|
$z -> execute; |
$z -> execute; |
($tourid, $tourname, $filename)= $z -> fetchrow; |
($tourid, $tourname, $filename)= $z -> fetchrow; |
|
|
|
|
$z= $qbase -> prepare("select QuestionId from questions WHERE ParentId = $tourid"); |
$z= $qbase -> prepare("select QuestionId from Questions WHERE ParentId = $tourid"); |
|
|
$z -> execute; |
$z -> execute; |
my $i; |
my $i; |
Line 102 sub out2in
|
Line 103 sub out2in
|
# |
# |
|
|
|
|
$z= $qbase -> prepare ( "select q.QuestionId from questions as q, |
$z= $qbase -> prepare ( "select q.QuestionId from Questions as q, |
tournaments as t1, tournaments as t2 |
Tournaments as t1, Tournaments as t2 |
where (t2.FileName= \"$q[0]\") && |
where (t2.FileName= \"$q[0]\") && |
(t1.ParentId = t2.Id) && |
(t1.ParentId = t2.Id) && |
(q.ParentId = t1.Id) && |
(q.ParentId = t1.Id) && |