Newer Older
106 lines | 2.401kb
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
    
version 0.0901
yuki-kimoto authored on 2009-12-17
31
    # New
32
    my $query = DBIx::Custom::Query->new;
33
    
34
    # Create by using create_query
35
    my $query = DBIx::Custom->create_query($template);
36
    
37
    # Set attributes
packaging one directory
yuki-kimoto authored on 2009-11-16
38
    $query->bind_filter($dbi->filters->{default_bind_filter});
39
    $query->no_bind_filters('title', 'author');
40
    
41
    $query->fetch_filter($dbi->filters->{default_fetch_filter});
42
    $query->no_fetch_filters('title', 'author');
43

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

            
46
=head2 sth
47

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

            
version 0.0901
yuki-kimoto authored on 2009-12-17
50
    $query = $query->sth($sth);
51
    $sth   = $query->sth;
packaging one directory
yuki-kimoto authored on 2009-11-16
52

            
53
=head2 sql
54

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

            
version 0.0901
yuki-kimoto authored on 2009-12-17
57
    $query = $query->sql($sql);
58
    $sql   = $query->sql;
packaging one directory
yuki-kimoto authored on 2009-11-16
59

            
60
=head2 bind_filter
61

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

            
version 0.0901
yuki-kimoto authored on 2009-12-17
64
    $query       = $query->bind_filter($bind_filter);
65
    $bind_filter = $query->bind_filter;
packaging one directory
yuki-kimoto authored on 2009-11-16
66

            
67
=head2 no_bind_filters
68

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

            
version 0.0901
yuki-kimoto authored on 2009-12-17
71
    $query           = $query->no_bind_filters($no_filters);
72
    $no_bind_filters = $query->no_bind_filters;
packaging one directory
yuki-kimoto authored on 2009-11-16
73

            
74
=head2 fetch_filter
75

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

            
version 0.0901
yuki-kimoto authored on 2009-12-17
78
    $query        = $query->fetch_filter($fetch_filter);
79
    $fetch_filter = $query->fetch_filter;
packaging one directory
yuki-kimoto authored on 2009-11-16
80

            
81
=head2 no_fetch_filters
82

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

            
version 0.0901
yuki-kimoto authored on 2009-12-17
85
    $query            = $query->no_fetch_filters($no_filters);
86
    $no_fetch_filters = $query->no_fetch_filters;
packaging one directory
yuki-kimoto authored on 2009-11-16
87

            
88
=head2 key_infos
89

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

            
version 0.0901
yuki-kimoto authored on 2009-12-17
92
    $query     = $query->key_infos($key_infos);
93
    $key_infos = $query->key_infos;
packaging one directory
yuki-kimoto authored on 2009-11-16
94

            
95
=head1 AUTHOR
96

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

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

            
101
=head1 COPYRIGHT & LICENSE
102

            
103
Copyright 2009 Yuki Kimoto, all rights reserved.
104

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