Newer Older
127 lines | 2.578kb
packaging one directory
yuki-kimoto authored on 2009-11-16
1
package DBIx::Custom::Query;
catch up with Object::Simple...
yuki-kimoto authored on 2010-01-22
2
use base 'Object::Simple';
packaging one directory
yuki-kimoto authored on 2009-11-16
3

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

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

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

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

            
packaging one directory
yuki-kimoto authored on 2009-11-16
36
=head1 NAME
37

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

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

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

            
57
=head2 sth
58

            
update document
yuki-kimoto authored on 2009-11-19
59
Set and get statement handle
60

            
version 0.0901
yuki-kimoto authored on 2009-12-17
61
    $query = $query->sth($sth);
62
    $sth   = $query->sth;
packaging one directory
yuki-kimoto authored on 2009-11-16
63

            
64
=head2 sql
65

            
update document
yuki-kimoto authored on 2009-11-19
66
Set and get SQL
67

            
version 0.0901
yuki-kimoto authored on 2009-12-17
68
    $query = $query->sql($sql);
69
    $sql   = $query->sql;
packaging one directory
yuki-kimoto authored on 2009-11-16
70

            
71
=head2 bind_filter
72

            
update document
yuki-kimoto authored on 2009-11-19
73
Set and get bind filter
74

            
version 0.0901
yuki-kimoto authored on 2009-12-17
75
    $query       = $query->bind_filter($bind_filter);
76
    $bind_filter = $query->bind_filter;
packaging one directory
yuki-kimoto authored on 2009-11-16
77

            
78
=head2 no_bind_filters
79

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

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

            
85
=head2 fetch_filter
86

            
update document
yuki-kimoto authored on 2009-11-19
87
Set and get fetch filter
88

            
version 0.0901
yuki-kimoto authored on 2009-12-17
89
    $query        = $query->fetch_filter($fetch_filter);
90
    $fetch_filter = $query->fetch_filter;
packaging one directory
yuki-kimoto authored on 2009-11-16
91

            
92
=head2 no_fetch_filters
93

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

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

            
99
=head2 key_infos
100

            
update document
yuki-kimoto authored on 2009-11-19
101
Set and get key informations
102

            
version 0.0901
yuki-kimoto authored on 2009-12-17
103
    $query     = $query->key_infos($key_infos);
104
    $key_infos = $query->key_infos;
packaging one directory
yuki-kimoto authored on 2009-11-16
105

            
cleanup
yuki-kimoto authored on 2009-12-22
106
=head1 Methods
107

            
108
=head2 new
109

            
110
    my $query = DBIx::Custom::Query->new;
111
    
packaging one directory
yuki-kimoto authored on 2009-11-16
112
=head1 AUTHOR
113

            
114
Yuki Kimoto, C<< <kimoto.yuki at gmail.com> >>
115

            
116
Github L<http://github.com/yuki-kimoto>
117

            
118
=head1 COPYRIGHT & LICENSE
119

            
120
Copyright 2009 Yuki Kimoto, all rights reserved.
121

            
122
This program is free software; you can redistribute it and/or modify it
123
under the same terms as Perl itself.
catch up with Object::Simple...
yuki-kimoto authored on 2010-01-22
124

            
125
=cut
126

            
127
1;