packaging one directory
|
1 |
package DBIx::Custom::Query; |
2 | ||
update document
|
3 |
use strict; |
4 |
use warnings; |
|
5 | ||
update document
|
6 |
use base 'Object::Simple'; |
7 | ||
cleanup
|
8 |
use Carp 'croak'; |
9 | ||
add table tag
|
10 |
__PACKAGE__->attr([qw/columns sql sth filters tables/]); |
cleanup
|
11 | |
12 |
sub filter { |
|
13 |
my $self = shift; |
|
14 |
|
|
15 |
if (@_) { |
|
16 |
my $filter = ref $_[0] eq 'HASH' ? $_[0] : {@_}; |
|
17 |
|
|
18 |
foreach my $column (keys %$filter) { |
|
19 |
my $fname = $filter->{$column}; |
|
20 | ||
21 |
if (exists $filter->{$column} |
|
22 |
&& defined $fname |
|
23 |
&& ref $fname ne 'CODE') |
|
24 |
{ |
|
25 |
croak qq{Filter "$fname" is not registered"} |
|
26 |
unless exists $self->filters->{$fname}; |
|
27 |
|
|
28 |
$filter->{$column} = $self->filters->{$fname}; |
|
29 |
} |
|
30 |
} |
|
31 |
|
|
32 |
$self->{filter} = {%{$self->filter}, %$filter}; |
|
33 |
|
|
34 |
return $self; |
|
35 |
} |
|
36 |
|
|
37 |
return $self->{filter} ||= {}; |
|
38 |
} |
|
cleanup
|
39 | |
40 |
# DEPRECATED! |
|
41 |
__PACKAGE__->attr('default_filter'); |
|
cleanup
|
42 | |
update document
|
43 |
1; |
44 | ||
packaging one directory
|
45 |
=head1 NAME |
46 | ||
removed DESTROY method(not b...
|
47 |
DBIx::Custom::Query - Query |
packaging one directory
|
48 | |
49 |
=head1 SYNOPSIS |
|
50 |
|
|
version 0.0901
|
51 |
my $query = DBIx::Custom::Query->new; |
52 |
|
|
update document
|
53 |
=head1 ATTRIBUTES |
packaging one directory
|
54 | |
removed DESTROY method(not b...
|
55 |
=head2 C<columns> |
removed reconnect method
|
56 | |
cleanup
|
57 |
my $columns = $query->columns; |
cleanup
|
58 |
$query = $query->columns(['auhtor', 'title']); |
removed reconnect method
|
59 | |
removed DESTROY method(not b...
|
60 |
Column names. |
packaging one directory
|
61 | |
removed DESTROY method(not b...
|
62 |
=head2 C<filter> |
update document
|
63 | |
cleanup
|
64 |
my $filter = $query->filter; |
cleanup
|
65 |
$query = $query->filter(author => 'to_something', |
66 |
title => 'to_something'); |
|
packaging one directory
|
67 | |
cleanup
|
68 |
Filters when parameter binding is executed. |
packaging one directory
|
69 | |
cleanup
|
70 |
=head2 C<sql> |
71 | ||
72 |
my $sql = $query->sql; |
|
73 |
$query = $query->sql('select * from books where author = ?;'); |
|
74 | ||
75 |
SQL statement. |
|
76 | ||
removed DESTROY method(not b...
|
77 |
=head2 C<sth> |
update document
|
78 | |
cleanup
|
79 |
my $sth = $query->sth; |
80 |
$query = $query->sth($sth); |
|
packaging one directory
|
81 | |
cleanup
|
82 |
Statement handle of L<DBI> |
removed DESTROY method(not b...
|
83 | |
update document
|
84 |
=head1 METHODS |
85 | ||
cleanup
|
86 |
L<DBIx::Custom::Query> inherits all methods from L<Object::Simple>. |
catch up with Object::Simple...
|
87 | |
88 |
=cut |