line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
7338
|
% my $a = shift; |
|
2
|
|
|
2
|
|
5
|
|
|
2
|
|
|
2
|
|
14
|
|
|
2
|
|
|
2
|
|
216
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
721
|
|
|
2
|
|
|
|
|
5891
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
193
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
695
|
|
2
|
|
|
|
|
|
|
package <%= $a->{class} %>; |
3
|
|
|
|
|
|
|
use Mojo::Base -base, -signatures; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
has '<%= $a->{db_helper} %>'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub add($self, $row) { |
8
|
|
|
|
|
|
|
return $self-><%= $a->{db_helper} %>->db->insert('<%= $a->{t} %>', $row)->last_insert_id; |
9
|
|
|
|
|
|
|
} |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub all($self, $opts = {}) { |
12
|
|
|
|
|
|
|
$opts->{limit} //= 100; |
13
|
|
|
|
|
|
|
$opts->{limit} = 100 unless $opts->{limit} =~/^\d+$/; |
14
|
|
|
|
|
|
|
$opts->{offset} //= 0; |
15
|
|
|
|
|
|
|
$opts->{offset} = 0 unless $opts->{offset} =~/^\d+$/; |
16
|
|
|
|
|
|
|
state $abstr = $self-><%= $a->{db_helper} %>->abstract; |
17
|
|
|
|
|
|
|
my ($sql, @bind) = $abstr->select('<%= $a->{t} %>', '*', $opts->{where}//()); |
18
|
|
|
|
|
|
|
$sql .= " LIMIT $opts->{limit}" . ($opts->{offset} ? " OFFSET $opts->{offset}" : ''); |
19
|
|
|
|
|
|
|
return $self-><%= $a->{db_helper} %>->db->query($sql, @bind)->hashes->to_array; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub find($self, $id) { |
23
|
|
|
|
|
|
|
return $self-><%= $a->{db_helper} %>->db->select('<%= $a->{t} %>', undef, {id => $id})->hash; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub remove($self, $id) { |
27
|
|
|
|
|
|
|
return $self-><%= $a->{db_helper} %>->db->delete('<%= $a->{t} %>', {id => $id}); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub save($self, $id, $row) { |
31
|
|
|
|
|
|
|
return $self-><%= $a->{db_helper} %>->db->update('<%= $a->{t} %>', $row, {id => $id}); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |