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