Newer Older
107 lines | 2.398kb
packaging one directory
yuki-kimoto authored on 2009-11-16
1
package DBIx::Custom::Query;
2
use Object::Simple;
3

            
update document
yuki-kimoto authored on 2009-11-17
4
use strict;
5
use warnings;
6

            
packaging one directory
yuki-kimoto authored on 2009-11-16
7
sub sql             : Attr {}
8
sub key_infos       : Attr {}
9
sub bind_filter     : Attr {}
10
sub fetch_filter     : Attr {}
11
sub sth             : Attr {}
12

            
13
sub no_bind_filters      : Attr { type => 'array', trigger => sub {
14
    my $self = shift;
15
    my $no_bind_filters = $self->no_bind_filters || [];
16
    my %no_bind_filters_map = map {$_ => 1} @{$no_bind_filters};
17
    $self->_no_bind_filters_map(\%no_bind_filters_map);
18
}}
19
sub _no_bind_filters_map : Attr {default => sub { {} }}
20

            
21
sub no_fetch_filters     : Attr { type => 'array', default => sub { [] } }
22

            
23
Object::Simple->build_class;
24

            
25
=head1 NAME
26

            
update document
yuki-kimoto authored on 2009-11-17
27
DBIx::Custom::Query - DBIx::Custom query
packaging one directory
yuki-kimoto authored on 2009-11-16
28

            
29
=head1 SYNOPSIS
30

            
31
    # Create query
32
    my $dbi = DBIx::Custom->new;
33
    my $query = $dbi->create_query($template);
34
    
35
    # Set query attributes
36
    $query->bind_filter($dbi->filters->{default_bind_filter});
37
    $query->no_bind_filters('title', 'author');
38
    
39
    $query->fetch_filter($dbi->filters->{default_fetch_filter});
40
    $query->no_fetch_filters('title', 'author');
41
    
42
    # Execute query
43
    $dbi->execute($query, $params);
44

            
update document
yuki-kimoto authored on 2009-11-19
45
=head1 Accessors
packaging one directory
yuki-kimoto authored on 2009-11-16
46

            
47
=head2 sth
48

            
update document
yuki-kimoto authored on 2009-11-19
49
Set and get statement handle
50

            
51
    $self = $self->sth($sql);
52
    $sth  = $self->sth;
packaging one directory
yuki-kimoto authored on 2009-11-16
53

            
54
=head2 sql
55

            
update document
yuki-kimoto authored on 2009-11-19
56
Set and get SQL
57

            
58
    $self = $self->sql($sql);
59
    $sql  = $self->sql;
packaging one directory
yuki-kimoto authored on 2009-11-16
60

            
61
=head2 bind_filter
62

            
update document
yuki-kimoto authored on 2009-11-19
63
Set and get bind filter
64

            
65
    $self        = $self->bind_filter($bind_filter);
66
    $bind_filter = $self->bind_filter;
packaging one directory
yuki-kimoto authored on 2009-11-16
67

            
68
=head2 no_bind_filters
69

            
update document
yuki-kimoto authored on 2009-11-19
70
Set and get keys of no filtering
71

            
72
    $self            = $self->no_bind_filters($no_filters);
73
    $no_bind_filters = $self->no_bind_filters;
packaging one directory
yuki-kimoto authored on 2009-11-16
74

            
75
=head2 fetch_filter
76

            
update document
yuki-kimoto authored on 2009-11-19
77
Set and get fetch filter
78

            
79
    $self         = $self->fetch_filter($fetch_filter);
80
    $fetch_filter = $self->fetch_filter;
packaging one directory
yuki-kimoto authored on 2009-11-16
81

            
82
=head2 no_fetch_filters
83

            
update document
yuki-kimoto authored on 2009-11-19
84
Set and get keys of no filtering
85

            
86
    $self             = $self->no_fetch_filters($no_filters);
87
    $no_fetch_filters = $self->no_fetch_filters;
packaging one directory
yuki-kimoto authored on 2009-11-16
88

            
89
=head2 key_infos
90

            
update document
yuki-kimoto authored on 2009-11-19
91
Set and get key informations
92

            
93
    $self      = $self->key_infos($key_infos);
94
    $key_infos = $self->key_infos;
packaging one directory
yuki-kimoto authored on 2009-11-16
95

            
96
=head1 AUTHOR
97

            
98
Yuki Kimoto, C<< <kimoto.yuki at gmail.com> >>
99

            
100
Github L<http://github.com/yuki-kimoto>
101

            
102
=head1 COPYRIGHT & LICENSE
103

            
104
Copyright 2009 Yuki Kimoto, all rights reserved.
105

            
106
This program is free software; you can redistribute it and/or modify it
107
under the same terms as Perl itself.