Newer Older
115 lines | 2.514kb
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

            
cleanup
yuki-kimoto authored on 2009-12-22
7
my $p = __PACKAGE__;
packaging one directory
yuki-kimoto authored on 2009-11-16
8

            
cleanup
yuki-kimoto authored on 2009-12-22
9
$p->attr([qw/sql key_infos bind_filter fetch_filter sth/])
10
  ->attr(_no_bind_filters_map => sub { {} })
11
  ->attr(no_fetch_filters => (type => 'array', default => sub { [] }));
12

            
13
$p->attr(no_bind_filters => (type => 'array', trigger => sub {
packaging one directory
yuki-kimoto authored on 2009-11-16
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);
cleanup
yuki-kimoto authored on 2009-12-22
18
}));
packaging one directory
yuki-kimoto authored on 2009-11-16
19

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

            
28
=head1 NAME
29

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

            
32
=head1 SYNOPSIS
33
    
version 0.0901
yuki-kimoto authored on 2009-12-17
34
    # New
35
    my $query = DBIx::Custom::Query->new;
36
    
37
    # Create by using create_query
38
    my $query = DBIx::Custom->create_query($template);
39
    
40
    # Set attributes
packaging one directory
yuki-kimoto authored on 2009-11-16
41
    $query->bind_filter($dbi->filters->{default_bind_filter});
42
    $query->no_bind_filters('title', 'author');
43
    
44
    $query->fetch_filter($dbi->filters->{default_fetch_filter});
45
    $query->no_fetch_filters('title', 'author');
46

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

            
49
=head2 sth
50

            
update document
yuki-kimoto authored on 2009-11-19
51
Set and get statement handle
52

            
version 0.0901
yuki-kimoto authored on 2009-12-17
53
    $query = $query->sth($sth);
54
    $sth   = $query->sth;
packaging one directory
yuki-kimoto authored on 2009-11-16
55

            
56
=head2 sql
57

            
update document
yuki-kimoto authored on 2009-11-19
58
Set and get SQL
59

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

            
63
=head2 bind_filter
64

            
update document
yuki-kimoto authored on 2009-11-19
65
Set and get bind filter
66

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

            
70
=head2 no_bind_filters
71

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

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

            
77
=head2 fetch_filter
78

            
update document
yuki-kimoto authored on 2009-11-19
79
Set and get fetch filter
80

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

            
84
=head2 no_fetch_filters
85

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

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

            
91
=head2 key_infos
92

            
update document
yuki-kimoto authored on 2009-11-19
93
Set and get key informations
94

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

            
cleanup
yuki-kimoto authored on 2009-12-22
98
=head1 Methods
99

            
100
=head2 new
101

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

            
106
Yuki Kimoto, C<< <kimoto.yuki at gmail.com> >>
107

            
108
Github L<http://github.com/yuki-kimoto>
109

            
110
=head1 COPYRIGHT & LICENSE
111

            
112
Copyright 2009 Yuki Kimoto, all rights reserved.
113

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