Commit | Line | Data |
19b913ce |
1 | package DBM::Deep::Iterator::DBI; |
2 | |
3 | use strict; |
4 | use warnings FATAL => 'all'; |
5 | |
6 | use base qw( DBM::Deep::Iterator ); |
7 | |
350896ee |
8 | sub reset { |
9 | my $self = shift; |
10 | |
11 | eval { $self->{sth}->finish; }; |
12 | delete $self->{sth}; |
13 | |
14 | return; |
15 | } |
16 | |
17 | sub get_next_key { |
18 | my $self = shift; |
19 | my ($obj) = @_; |
20 | |
21 | unless ( exists $self->{sth} ) { |
22 | $self->{sth} = $self->{engine}->storage->{dbh}->prepare( |
23 | "SELECT `key` FROM datas WHERE ref_id = ? ORDER BY RAND()", |
24 | ); |
25 | $self->{sth}->execute( $self->{base_offset} ); |
26 | } |
27 | |
28 | my ($key) = $self->{sth}->fetchrow_array; |
29 | return $key; |
30 | } |
31 | |
19b913ce |
32 | 1; |
33 | __END__ |