packaging one directory
|
1 |
package DBIx::Custom::Query; |
updatedd pod
|
2 |
use Object::Simple -base; |
update document
|
3 | |
cleanup
|
4 |
use Carp 'croak'; |
cleanup
|
5 |
use DBIx::Custom::Util '_subname'; |
cleanup
|
6 | |
DBIx::Custom::Query filters ...
|
7 |
has 'sth', |
- update_param_tag is DEPREC...
|
8 |
sql => '', |
updatedd pod
|
9 |
columns => sub { [] }; |
cleanup
|
10 | |
DBIx::Custom::Query filters ...
|
11 |
# DEPRECATED! |
12 |
has 'default_filter'; |
|
13 |
sub filters { |
|
14 |
warn "DBIx::Custom::Query filters attribute method is DEPRECATED!"; |
|
15 |
my $self = shift; |
|
16 |
if (@_) { |
|
17 |
$self->{filters} = $_[0]; |
|
18 |
return $self; |
|
19 |
} |
|
20 |
return $self->{filters}; |
|
21 |
} |
|
22 |
has tables => sub { [] }; |
|
23 | ||
24 |
#DEPRECATED! |
|
cleanup
|
25 |
sub filter { |
DBIx::Custom::Query filters ...
|
26 |
warn "DBIx::Custom::Query filter method is DEPRECATED!"; |
cleanup
|
27 |
my $self = shift; |
28 |
if (@_) { |
|
all filter can receive array...
|
29 |
my $filter = {}; |
30 |
if (ref $_[0] eq 'HASH') { |
|
31 |
$filter = $_[0]; |
|
32 |
} |
|
33 |
else { |
|
34 |
my $ef = @_ > 1 ? [@_] : $_[0]; |
|
35 |
for (my $i = 0; $i < @$ef; $i += 2) { |
|
36 |
my $column = $ef->[$i]; |
|
37 |
my $f = $ef->[$i + 1]; |
|
38 |
if (ref $column eq 'ARRAY') { |
|
39 |
foreach my $c (@$column) { |
|
40 |
$filter->{$c} = $f; |
|
41 |
} |
|
42 |
} |
|
43 |
else { |
|
44 |
$filter->{$column} = $f; |
|
45 |
} |
|
46 |
} |
|
47 |
} |
|
cleanup
|
48 |
foreach my $column (keys %$filter) { |
49 |
my $fname = $filter->{$column}; |
|
50 |
if (exists $filter->{$column} |
|
51 |
&& defined $fname |
|
52 |
&& ref $fname ne 'CODE') |
|
53 |
{ |
|
DBIx::Custom::Query filters ...
|
54 |
my $filters = $self->{filters} || {}; |
55 |
croak qq{Filter "$fname" is not registered" } . _subname |
|
56 |
unless exists $filters->{$fname}; |
|
57 |
$filter->{$column} = $filters->{$fname}; |
|
cleanup
|
58 |
} |
59 |
} |
|
60 |
$self->{filter} = {%{$self->filter}, %$filter}; |
|
61 |
return $self; |
|
62 |
} |
|
63 |
return $self->{filter} ||= {}; |
|
64 |
} |
|
cleanup
|
65 | |
update document
|
66 |
1; |
67 | ||
packaging one directory
|
68 |
=head1 NAME |
69 | ||
removed DESTROY method(not b...
|
70 |
DBIx::Custom::Query - Query |
packaging one directory
|
71 | |
72 |
=head1 SYNOPSIS |
|
73 |
|
|
version 0.0901
|
74 |
my $query = DBIx::Custom::Query->new; |
DBIx::Custom::Query filters ...
|
75 |
my $sth = $query->sth; |
76 |
my $sql = $query->sql; |
|
77 |
my $columns = $query->columns; |
|
version 0.0901
|
78 |
|
update document
|
79 |
=head1 ATTRIBUTES |
packaging one directory
|
80 | |
removed DESTROY method(not b...
|
81 |
=head2 C<columns> |
removed reconnect method
|
82 | |
cleanup
|
83 |
my $columns = $query->columns; |
cleanup
|
84 |
$query = $query->columns(['auhtor', 'title']); |
removed reconnect method
|
85 | |
removed DESTROY method(not b...
|
86 |
Column names. |
packaging one directory
|
87 | |
cleanup
|
88 |
=head2 C<sql> |
89 | ||
90 |
my $sql = $query->sql; |
|
91 |
$query = $query->sql('select * from books where author = ?;'); |
|
92 | ||
93 |
SQL statement. |
|
94 | ||
removed DESTROY method(not b...
|
95 |
=head2 C<sth> |
update document
|
96 | |
cleanup
|
97 |
my $sth = $query->sth; |
98 |
$query = $query->sth($sth); |
|
packaging one directory
|
99 | |
cleanup
|
100 |
Statement handle of L<DBI> |
removed DESTROY method(not b...
|
101 | |
update document
|
102 |
=head1 METHODS |
103 | ||
cleanup
|
104 |
L<DBIx::Custom::Query> inherits all methods from L<Object::Simple>. |
catch up with Object::Simple...
|
105 | |
106 |
=cut |