line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::DBI::AbstractSearch; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
765
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
4
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION @EXPORT); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
90
|
|
5
|
|
|
|
|
|
|
$VERSION = 0.07; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
*import = \&Exporter::import; |
9
|
|
|
|
|
|
|
@EXPORT = qw(search_where); |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
1091
|
use SQL::Abstract::Limit; |
|
1
|
|
|
|
|
25292
|
|
|
1
|
|
|
|
|
287
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub search_where { |
14
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
15
|
0
|
0
|
|
|
|
|
my $where = (ref $_[0]) ? $_[0] : { @_ }; |
16
|
0
|
0
|
|
|
|
|
my $attr = (ref $_[0]) ? $_[1] : undef; |
17
|
0
|
0
|
|
|
|
|
my $order = ($attr) ? delete($attr->{order_by}) : undef; |
18
|
0
|
0
|
|
|
|
|
my $limit = ($attr) ? delete($attr->{limit}) : undef; |
19
|
0
|
0
|
|
|
|
|
my $offset = ($attr) ? delete($attr->{offset}) : undef; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# order is deprecated, but still backward compatible |
22
|
0
|
0
|
0
|
|
|
|
if ($attr && exists($attr->{order})) { |
23
|
0
|
|
|
|
|
|
$order = delete($attr->{order}); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
0
|
0
|
|
|
|
|
$class->can('retrieve_from_sql') or do { |
27
|
0
|
|
|
|
|
|
require Carp; |
28
|
0
|
|
|
|
|
|
Carp::croak("$class should inherit from Class::DBI >= 0.90"); |
29
|
|
|
|
|
|
|
}; |
30
|
0
|
|
|
|
|
|
my $sql = SQL::Abstract::Limit->new(%$attr); |
31
|
0
|
|
|
|
|
|
my($phrase, @bind) = $sql->where($where, $order, $limit, $offset); |
32
|
0
|
|
|
|
|
|
$phrase =~ s/^\s*WHERE\s*//i; |
33
|
0
|
|
|
|
|
|
return $class->retrieve_from_sql($phrase, @bind); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
__END__ |