I want to make a global that pops out a random link from all those added in the current month. Here is the global I wrote: ('date_user_format_one' is definded as "%yyyy%-%mm%" in config...)
sub {
my $db = $DB->table('Links');
Links::init_date();
GT::Date::date_set_format($CFG->{'date_user_format_one'});
my $to_date = GT::Date::date_get();
GT::Date::date_set_format($CFG->{'date_db_format'});
my $cond = GT::SQL::Condition->new(
'isValidated', '=', 'Yes',
'Add_Date', 'LIKE', '$to_date%'
);
my $total = $db->count ( $cond );
my $rand = int( rand($total) );
$db->select_options ("LIMIT $rand, 1");
my $link = $db->select->fetchrow_hashref;
my $html = Links::SiteHTML::display('link', $link);
return $html;
}
OK, I tested, and $to_date works fine- it returns 2004-03 right now. But the global as a whole always returns the same ONE record, and one NOT entered in the current month.
Anyone see what I might have done wrong here
TIA
dave
Big Cartoon DataBase
Big Comic Book DataBase
sub {
my $db = $DB->table('Links');
Links::init_date();
GT::Date::date_set_format($CFG->{'date_user_format_one'});
my $to_date = GT::Date::date_get();
GT::Date::date_set_format($CFG->{'date_db_format'});
my $cond = GT::SQL::Condition->new(
'isValidated', '=', 'Yes',
'Add_Date', 'LIKE', '$to_date%'
);
my $total = $db->count ( $cond );
my $rand = int( rand($total) );
$db->select_options ("LIMIT $rand, 1");
my $link = $db->select->fetchrow_hashref;
my $html = Links::SiteHTML::display('link', $link);
return $html;
}
OK, I tested, and $to_date works fine- it returns 2004-03 right now. But the global as a whole always returns the same ONE record, and one NOT entered in the current month.
Anyone see what I might have done wrong here
TIA
dave
Big Cartoon DataBase
Big Comic Book DataBase