Newer Older
120 lines | 2.437kb
packaging one directory
yuki-kimoto authored on 2009-11-16
1
package DBIx::Custom::Query;
2

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

            
update document
yuki-kimoto authored on 2010-01-30
6
use base 'Object::Simple';
7

            
catch up with Object::Simple...
yuki-kimoto authored on 2010-01-18
8
__PACKAGE__->attr([qw/sql key_infos bind_filter fetch_filter sth/]);
cleanup
yuki-kimoto authored on 2010-01-21
9
__PACKAGE__->attr(_no_bind_filters => sub { {} });
catch up with Object::Simple...
yuki-kimoto authored on 2010-01-18
10
__PACKAGE__->attr(no_fetch_filters => sub { [] });
packaging one directory
yuki-kimoto authored on 2009-11-16
11

            
cleanup
yuki-kimoto authored on 2009-12-22
12
sub new {
13
    my $self = shift->SUPER::new(@_);
14
    
update document
yuki-kimoto authored on 2010-01-30
15
    # Initialize attributes
cleanup
yuki-kimoto authored on 2010-01-21
16
    $self->no_bind_filters($self->{no_bind_filters})
17
      if $self->{no_bind_filters};
cleanup
yuki-kimoto authored on 2009-12-22
18
    
19
    return $self;
20
}
packaging one directory
yuki-kimoto authored on 2009-11-16
21

            
cleanup
yuki-kimoto authored on 2010-01-21
22
sub no_bind_filters {
23
    my $self = shift;
24
    
25
    if (@_) {
update document
yuki-kimoto authored on 2010-01-30
26
        # Set
cleanup
yuki-kimoto authored on 2010-01-21
27
        $self->{no_bind_filters} = $_[0];
28
        
update document
yuki-kimoto authored on 2010-01-30
29
        # Cached
cleanup
yuki-kimoto authored on 2010-01-21
30
        my %no_bind_filters = map { $_ => 1 } @{$self->{no_bind_filters}};
31
        $self->_no_bind_filters(\%no_bind_filters);
32
        
33
        return $self;
34
    }
35
    
36
    return $self->{no_bind_filters};
37
}
38

            
update document
yuki-kimoto authored on 2010-01-30
39
1;
40

            
packaging one directory
yuki-kimoto authored on 2009-11-16
41
=head1 NAME
42

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

            
45
=head1 SYNOPSIS
46
    
version 0.0901
yuki-kimoto authored on 2009-12-17
47
    # New
48
    my $query = DBIx::Custom::Query->new;
49
    
50
    # Create by using create_query
51
    my $query = DBIx::Custom->create_query($template);
52
    
53
    # Set attributes
packaging one directory
yuki-kimoto authored on 2009-11-16
54
    $query->bind_filter($dbi->filters->{default_bind_filter});
55
    $query->no_bind_filters('title', 'author');
56
    
57
    $query->fetch_filter($dbi->filters->{default_fetch_filter});
58
    $query->no_fetch_filters('title', 'author');
59

            
update document
yuki-kimoto authored on 2010-01-30
60
=head1 ATTRIBUTES
packaging one directory
yuki-kimoto authored on 2009-11-16
61

            
62
=head2 sth
63

            
update document
yuki-kimoto authored on 2010-01-30
64
Statement handle
update document
yuki-kimoto authored on 2009-11-19
65

            
version 0.0901
yuki-kimoto authored on 2009-12-17
66
    $query = $query->sth($sth);
67
    $sth   = $query->sth;
packaging one directory
yuki-kimoto authored on 2009-11-16
68

            
69
=head2 sql
70

            
update document
yuki-kimoto authored on 2010-01-30
71
SQL
update document
yuki-kimoto authored on 2009-11-19
72

            
version 0.0901
yuki-kimoto authored on 2009-12-17
73
    $query = $query->sql($sql);
74
    $sql   = $query->sql;
packaging one directory
yuki-kimoto authored on 2009-11-16
75

            
76
=head2 bind_filter
77

            
update document
yuki-kimoto authored on 2010-01-30
78
Filter excuted when value is bind
update document
yuki-kimoto authored on 2009-11-19
79

            
version 0.0901
yuki-kimoto authored on 2009-12-17
80
    $query       = $query->bind_filter($bind_filter);
81
    $bind_filter = $query->bind_filter;
packaging one directory
yuki-kimoto authored on 2009-11-16
82

            
83
=head2 no_bind_filters
84

            
update document
yuki-kimoto authored on 2010-01-30
85
Key list which dose not have to bind filtering
update document
yuki-kimoto authored on 2009-11-19
86

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

            
90
=head2 fetch_filter
91

            
update document
yuki-kimoto authored on 2010-01-30
92
Filter excuted when data is fetched
update document
yuki-kimoto authored on 2009-11-19
93

            
version 0.0901
yuki-kimoto authored on 2009-12-17
94
    $query        = $query->fetch_filter($fetch_filter);
95
    $fetch_filter = $query->fetch_filter;
packaging one directory
yuki-kimoto authored on 2009-11-16
96

            
97
=head2 no_fetch_filters
98

            
update document
yuki-kimoto authored on 2010-01-30
99
Key list which dose not have to fetch filtering
update document
yuki-kimoto authored on 2009-11-19
100

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

            
104
=head2 key_infos
105

            
update document
yuki-kimoto authored on 2010-01-30
106
Key informations
update document
yuki-kimoto authored on 2009-11-19
107

            
version 0.0901
yuki-kimoto authored on 2009-12-17
108
    $query     = $query->key_infos($key_infos);
109
    $key_infos = $query->key_infos;
packaging one directory
yuki-kimoto authored on 2009-11-16
110

            
update document
yuki-kimoto authored on 2010-01-30
111
=head1 METHODS
112

            
113
This class is L<Object::Simple> subclass.
114
You can use all methods of L<Object::Simple>
cleanup
yuki-kimoto authored on 2009-12-22
115

            
116
=head2 new
117

            
118
    my $query = DBIx::Custom::Query->new;
catch up with Object::Simple...
yuki-kimoto authored on 2010-01-22
119

            
120
=cut