View | Details | Raw Unified | Return to bug 11279
Collapse All | Expand All

(-)a/C4/Koha.pm (-4 / +7 lines)
Lines 29-34 use Koha::DateUtils qw(dt_from_string); Link Here
29
use Memoize;
29
use Memoize;
30
use DateTime::Format::MySQL;
30
use DateTime::Format::MySQL;
31
use autouse 'Data::Dumper' => qw(Dumper);
31
use autouse 'Data::Dumper' => qw(Dumper);
32
use DBI qw(:sql_types);
32
33
33
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $DEBUG);
34
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $DEBUG);
34
35
Lines 1443-1453 sub GetDailyQuote { Link Here
1443
        my $range = ($sth->fetchrow_array)[0];
1444
        my $range = ($sth->fetchrow_array)[0];
1444
        if ($range > 1) {
1445
        if ($range > 1) {
1445
            # chose a random id within that range if there is more than one quote
1446
            # chose a random id within that range if there is more than one quote
1446
            my $id = int(rand($range));
1447
            my $offset = int(rand($range));
1447
            # grab it
1448
            # grab it
1448
            $query = 'SELECT * FROM quotes WHERE id = ?;';
1449
            $query = 'SELECT * FROM quotes ORDER BY id LIMIT 1 OFFSET ?';
1449
            $sth = C4::Context->dbh->prepare($query);
1450
            $sth = C4::Context->dbh->prepare($query);
1450
            $sth->execute($id);
1451
            # see http://www.perlmonks.org/?node_id=837422 for why
1452
            # we're being verbose and using bind_param
1453
            $sth->bind_param(1, $offset, SQL_INTEGER);
1454
            $sth->execute();
1451
        }
1455
        }
1452
        else {
1456
        else {
1453
            $query = 'SELECT * FROM quotes;';
1457
            $query = 'SELECT * FROM quotes;';
1454
- 

Return to bug 11279