version 1.70, 2002/06/20 12:54:52
|
version 1.71, 2002/08/01 23:14:00
|
Line 1160 sub Get12Random {
|
Line 1160 sub Get12Random {
|
my ($qnum) = &GetMaxQId($dbh); |
my ($qnum) = &GetMaxQId($dbh); |
my (%chosen); |
my (%chosen); |
srand; |
srand; |
|
|
my $where=0; |
my $where=0; |
my $r=int (rand(10000)); |
my $r=int (rand(10000)); |
|
|
Line 1172 sub Get12Random {
|
Line 1171 sub Get12Random {
|
|
|
$q="select QuestionId, QuestionId/$r-floor(QuestionId/$r) as val |
$q="select QuestionId, QuestionId/$r-floor(QuestionId/$r) as val |
from Questions where $where order by val limit $num"; |
from Questions where $where order by val limit $num"; |
|
|
# Когда на куличках появится mysql >=3.23 надо заменить на order by rand(); |
# Когда на куличках появится mysql >=3.23 надо заменить на order by rand(); |
|
|
$sth=$dbh->prepare($q); |
$sth=$dbh->prepare($q); |