| Server IP : 127.0.0.1 / Your IP : 216.73.216.48 Web Server : Apache/2.4.58 (Win64) OpenSSL/3.1.3 PHP/8.2.12 System : Windows NT DESKTOP-3H4FHQJ 10.0 build 19045 (Windows 10) AMD64 User : win 10 ( 0) PHP Version : 8.2.12 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/xampp/perl/vendor/lib/DBM/Deep/Iterator/ |
Upload File : |
package DBM::Deep::Iterator::DBI;
use strict;
use warnings FATAL => 'all';
use base qw( DBM::Deep::Iterator );
sub reset {
my $self = shift;
eval { $self->{sth}->finish; };
delete $self->{sth};
return;
}
sub get_next_key {
my $self = shift;
my ($obj) = @_;
unless ( exists $self->{sth} ) {
# For mysql, this needs to be RAND()
# For sqlite, this needs to be random()
my $storage = $self->{engine}->storage;
$self->{sth} = $storage->{dbh}->prepare(
"SELECT `key` FROM datas WHERE ref_id = ? ORDER BY "
. $storage->rand_function,
);
$self->{sth}->execute( $self->{base_offset} );
}
my ($key) = $self->{sth}->fetchrow_array;
return $key;
}
1;
__END__