| 1 | package DBM::Deep::Iterator::DBI; | ||||||||||
| 2 | |||||||||||
| 3 | 48 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 48 | ▶ | use warnings FATAL => 'all'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 48 | ▶ | use base qw( DBM::Deep::Iterator ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | sub reset { | ||||||||||
| 9 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
reset: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 10 | |||||||||||
| 11 | 0 | eval { $self->{sth}->finish; }; | |||||||||
| 12 | 0 | delete $self->{sth}; | |||||||||
| 13 | |||||||||||
| 14 | 0 | return; | |||||||||
| 15 | } | ||||||||||
| 16 | |||||||||||
| 17 | sub get_next_key { | ||||||||||
| 18 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
get_next_key: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 19 | 0 | my ($obj) = @_; | |||||||||
| 20 | |||||||||||
| 21 | 0 | ▶ | unless ( exists $self->{sth} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | # For mysql, this needs to be RAND() | ||||||||||
| 23 | # For sqlite, this needs to be random() | ||||||||||
| 24 | 0 | my $storage = $self->{engine}->storage; | |||||||||
| 25 | $self->{sth} = $storage->{dbh}->prepare( | ||||||||||
| 26 | 0 | "SELECT `key` FROM datas WHERE ref_id = ? ORDER BY " | |||||||||
| 27 | . $storage->rand_function, | ||||||||||
| 28 | ); | ||||||||||
| 29 | 0 | $self->{sth}->execute( $self->{base_offset} ); | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | 0 | my ($key) = $self->{sth}->fetchrow_array; | |||||||||
| 33 | 0 | return $key; | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 48 | 1; | |||||||||
| 37 | __END__ | ||||||||||