packing
|
1 |
package DBIx::Custom::Query; |
2 |
use Object::Simple; |
|
3 | ||
4 |
our $VERSION = '0.0101'; |
|
5 | ||
6 |
sub sql : Attr {} |
|
7 |
sub key_infos : Attr {} |
|
8 |
sub bind_filter : Attr {} |
|
9 |
sub fetch_filter : Attr {} |
|
10 |
sub sth : Attr {} |
|
11 | ||
12 |
sub no_bind_filters : Attr { type => 'array', trigger => sub { |
|
13 |
my $self = shift; |
|
14 |
my $no_bind_filters = $self->no_bind_filters || []; |
|
15 |
my %no_bind_filters_map = map {$_ => 1} @{$no_bind_filters}; |
|
16 |
$self->_no_bind_filters_map(\%no_bind_filters_map); |
|
17 |
}} |
|
18 |
sub _no_bind_filters_map : Attr {default => sub { {} }} |
|
19 | ||
20 |
sub no_fetch_filters : Attr { type => 'array', default => sub { [] } } |
|
21 | ||
22 |
Object::Simple->build_class; |
|
23 | ||
24 |
=head1 NAME |
|
25 | ||
26 |
DBIx::Custom::Query - Query object for DBIx::Custom |
|
27 | ||
28 |
=head1 VERSION |
|
29 | ||
30 |
Version 0.0101 |
|
31 | ||
32 |
=head1 SYNOPSIS |
|
33 | ||
34 |
# Create query |
|
35 |
my $dbi = DBIx::Custom->new; |
|
36 |
my $query = $dbi->create_query($template); |
|
37 |
|
|
38 |
# Set query attributes |
|
39 |
$query->bind_filter($dbi->filters->{default_bind_filter}); |
|
40 |
$query->no_bind_filters('title', 'author'); |
|
41 |
|
|
42 |
$query->fetch_filter($dbi->filters->{default_fetch_filter}); |
|
43 |
$query->no_fetch_filters('title', 'author'); |
|
44 |
|
|
45 |
# Execute query |
|
46 |
$dbi->execute($query, $params); |
|
47 | ||
48 |
=head1 OBJECT ACCESSORS |
|
49 | ||
50 |
=head2 sth |
|
51 | ||
52 |
# Set and get statement handle |
|
53 |
$self = $query->sth($sql); |
|
54 |
$sth = $query->sth; |
|
55 | ||
56 |
=head2 sql |
|
57 | ||
58 |
# Set and get SQL |
|
59 |
$self = $query->sql($sql); |
|
60 |
$sql = $query->sql; |
|
61 | ||
62 |
=head2 bind_filter |
|
63 | ||
64 |
# Set and get bind filter |
|
65 |
$self = $query->bind_filter($bind_filter); |
|
66 |
$bind_filter = $query->bind_filter; |
|
67 | ||
68 |
=head2 no_bind_filters |
|
69 | ||
70 |
# Set and get keys of no filtering |
|
71 |
$self = $query->no_bind_filters($no_filters); |
|
72 |
$no_bind_filters = $query->no_bind_filters; |
|
73 | ||
74 |
=head2 fetch_filter |
|
75 | ||
76 |
# Set and get fetch filter |
|
77 |
$self = $query->fetch_filter($fetch_filter); |
|
78 |
$fetch_filter = $query->fetch_filter; |
|
79 | ||
80 |
=head2 no_fetch_filters |
|
81 | ||
82 |
# Set and get keys of no filtering |
|
83 |
$self = $query->no_fetch_filters($no_filters); |
|
84 |
$no_fetch_filters = $query->no_fetch_filters; |
|
85 | ||
86 |
=head2 key_infos |
|
87 | ||
88 |
# Set and get key informations |
|
89 |
$self = $query->key_infos($key_infos); |
|
90 |
$key_infos = $query->key_infos; |
|
91 | ||
92 |
=head1 AUTHOR |
|
93 | ||
94 |
Yuki Kimoto, C<< <kimoto.yuki at gmail.com> >> |
|
95 | ||
96 |
Github L<http://github.com/yuki-kimoto> |
|
97 | ||
98 |
=head1 COPYRIGHT & LICENSE |
|
99 | ||
100 |
Copyright 2009 Yuki Kimoto, all rights reserved. |
|
101 | ||
102 |
This program is free software; you can redistribute it and/or modify it |
|
103 |
under the same terms as Perl itself. |