Newer Older
113 lines | 2.481kb
packaging one directory
yuki-kimoto authored on 2009-11-16
1
package DBIx::Custom::Query;
cleanup
yuki-kimoto authored on 2009-12-22
2
use base 'Object::Simple::Base';
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/]);
8
__PACKAGE__->attr(_no_bind_filters_map => sub { {} });
9
__PACKAGE__->attr(no_fetch_filters => sub { [] });
packaging one directory
yuki-kimoto authored on 2009-11-16
10

            
catch up with Object::Simple...
yuki-kimoto authored on 2010-01-18
11
__PACKAGE__->attr('no_bind_filters', trigger => sub {
packaging one directory
yuki-kimoto authored on 2009-11-16
12
    my $self = shift;
13
    my $no_bind_filters = $self->no_bind_filters || [];
14
    my %no_bind_filters_map = map {$_ => 1} @{$no_bind_filters};
15
    $self->_no_bind_filters_map(\%no_bind_filters_map);
catch up with Object::Simple...
yuki-kimoto authored on 2010-01-18
16
});
packaging one directory
yuki-kimoto authored on 2009-11-16
17

            
cleanup
yuki-kimoto authored on 2009-12-22
18
sub new {
19
    my $self = shift->SUPER::new(@_);
20
    
21
    Object::Simple::Util->init_attrs($self, 'no_bind_filters');
22
    
23
    return $self;
24
}
packaging one directory
yuki-kimoto authored on 2009-11-16
25

            
26
=head1 NAME
27

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

            
30
=head1 SYNOPSIS
31
    
version 0.0901
yuki-kimoto authored on 2009-12-17
32
    # New
33
    my $query = DBIx::Custom::Query->new;
34
    
35
    # Create by using create_query
36
    my $query = DBIx::Custom->create_query($template);
37
    
38
    # Set attributes
packaging one directory
yuki-kimoto authored on 2009-11-16
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

            
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

            
version 0.0901
yuki-kimoto authored on 2009-12-17
51
    $query = $query->sth($sth);
52
    $sth   = $query->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

            
version 0.0901
yuki-kimoto authored on 2009-12-17
58
    $query = $query->sql($sql);
59
    $sql   = $query->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

            
version 0.0901
yuki-kimoto authored on 2009-12-17
65
    $query       = $query->bind_filter($bind_filter);
66
    $bind_filter = $query->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

            
version 0.0901
yuki-kimoto authored on 2009-12-17
72
    $query           = $query->no_bind_filters($no_filters);
73
    $no_bind_filters = $query->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

            
version 0.0901
yuki-kimoto authored on 2009-12-17
79
    $query        = $query->fetch_filter($fetch_filter);
80
    $fetch_filter = $query->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

            
version 0.0901
yuki-kimoto authored on 2009-12-17
86
    $query            = $query->no_fetch_filters($no_filters);
87
    $no_fetch_filters = $query->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

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

            
cleanup
yuki-kimoto authored on 2009-12-22
96
=head1 Methods
97

            
98
=head2 new
99

            
100
    my $query = DBIx::Custom::Query->new;
101
    
packaging one directory
yuki-kimoto authored on 2009-11-16
102
=head1 AUTHOR
103

            
104
Yuki Kimoto, C<< <kimoto.yuki at gmail.com> >>
105

            
106
Github L<http://github.com/yuki-kimoto>
107

            
108
=head1 COPYRIGHT & LICENSE
109

            
110
Copyright 2009 Yuki Kimoto, all rights reserved.
111

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