Home : Products : Gossamer Links : Development, Plugins and Globals :

Products: Gossamer Links: Development, Plugins and Globals: Re: [regatta] random id global: Edit Log

Here is the list of edits for this post
Re: [regatta] random id global
Try this. It's from Jump.pm

Code:
sub {
my $db = $DB->table('Links');
my $total = $db->total() - $db->count({ isValidated => 'No' });
my $offset = int rand $total;
$db->select_options ("LIMIT $offset, 1");
my $sth = $db->select ( { isValidated => 'Yes'} , ['ID']);
my ($id) = $sth->fetchrow_array;
return ($id);
}

It doesn't rely on the RAND function in queries.


PUGDOG´┐Ż Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.

Last edited by:

pugdog: Apr 25, 2005, 6:05 PM

Edit Log: