Newer Older
116 lines | 2.616kb
packaging one directory
yuki-kimoto authored on 2009-11-16
1
package DBIx::Custom::Query;
updatedd pod
Yuki Kimoto authored on 2011-06-12
2
use Object::Simple -base;
update document
yuki-kimoto authored on 2010-01-30
3

            
cleanup
Yuki Kimoto authored on 2011-02-09
4
use Carp 'croak';
cleanup
Yuki Kimoto authored on 2011-04-25
5
use DBIx::Custom::Util '_subname';
cleanup
Yuki Kimoto authored on 2011-02-09
6

            
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
7
has 'sth',
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
8
    sql => '',
updatedd pod
Yuki Kimoto authored on 2011-06-12
9
    columns => sub { [] };
cleanup
Yuki Kimoto authored on 2011-02-09
10

            
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
11
# DEPRECATED!
12
has 'default_filter';
13
sub filters {
14
    warn "DBIx::Custom::Query filters attribute method is DEPRECATED!";
15
    my $self = shift;
16
    if (@_) {
17
        $self->{filters} = $_[0];
18
        return $self;
19
    }
20
    return $self->{filters};
21
}
DBIx::Custom::Query tables a...
Yuki Kimoto authored on 2011-07-30
22

            
23
# DEPRECATED!
24
sub tables {
25
    warn "DBIx::Custom::Query tables attribute method is DEPRECATED!";
26
    my $self = shift;
27
    if (@_) {
28
        $self->{tables} = $_[0];
29
        return $self;
30
    }
31
    return $self->{tables} ||= [];
32
}
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
33

            
34
#DEPRECATED!
cleanup
Yuki Kimoto authored on 2011-02-09
35
sub filter {
DBIx::Custom::Query tables a...
Yuki Kimoto authored on 2011-07-30
36
    #warn "DBIx::Custom::Query filter method is DEPRECATED!";
cleanup
Yuki Kimoto authored on 2011-02-09
37
    my $self = shift;
38
    if (@_) {
all filter can receive array...
Yuki Kimoto authored on 2011-02-25
39
        my $filter = {};
40
        if (ref $_[0] eq 'HASH') {
41
            $filter = $_[0];
42
        }
43
        else {
44
            my $ef = @_ > 1 ? [@_] : $_[0];
45
            for (my $i = 0; $i < @$ef; $i += 2) {
46
                my $column = $ef->[$i];
47
                my $f = $ef->[$i + 1];
48
                if (ref $column eq 'ARRAY') {
49
                    foreach my $c (@$column) {
50
                        $filter->{$c} = $f;
51
                    }
52
                }
53
                else {
54
                    $filter->{$column} = $f;
55
                }
56
            }
57
        }
cleanup
Yuki Kimoto authored on 2011-02-09
58
        foreach my $column (keys %$filter) {
59
            my $fname = $filter->{$column};
60
            if  (exists $filter->{$column}
61
              && defined $fname
62
              && ref $fname ne 'CODE') 
63
            {
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
64
                my $filters = $self->{filters} || {};
65
                croak qq{Filter "$fname" is not registered" } . _subname
66
                  unless exists $filters->{$fname};
67
                $filter->{$column} = $filters->{$fname};
cleanup
Yuki Kimoto authored on 2011-02-09
68
            }
69
        }
70
        $self->{filter} = {%{$self->filter}, %$filter};
71
        return $self;
72
    }
73
    return $self->{filter} ||= {};
74
}
cleanup
Yuki Kimoto authored on 2011-01-23
75

            
update document
yuki-kimoto authored on 2010-01-30
76
1;
77

            
packaging one directory
yuki-kimoto authored on 2009-11-16
78
=head1 NAME
79

            
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
80
DBIx::Custom::Query - Query
packaging one directory
yuki-kimoto authored on 2009-11-16
81

            
82
=head1 SYNOPSIS
83
    
version 0.0901
yuki-kimoto authored on 2009-12-17
84
    my $query = DBIx::Custom::Query->new;
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
85
    my $sth = $query->sth;
86
    my $sql = $query->sql;
87
    my $columns = $query->columns;
version 0.0901
yuki-kimoto authored on 2009-12-17
88
    
update document
yuki-kimoto authored on 2010-01-30
89
=head1 ATTRIBUTES
packaging one directory
yuki-kimoto authored on 2009-11-16
90

            
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
91
=head2 C<columns>
removed reconnect method
yuki-kimoto authored on 2010-05-28
92

            
cleanup
yuki-kimoto authored on 2010-08-03
93
    my $columns = $query->columns;
cleanup
yuki-kimoto authored on 2010-08-05
94
    $query      = $query->columns(['auhtor', 'title']);
removed reconnect method
yuki-kimoto authored on 2010-05-28
95

            
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
96
Column names.
packaging one directory
yuki-kimoto authored on 2009-11-16
97

            
cleanup
yuki-kimoto authored on 2010-10-17
98
=head2 C<sql>
99

            
100
    my $sql = $query->sql;
101
    $query  = $query->sql('select * from books where author = ?;');
102

            
103
SQL statement.
104

            
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
105
=head2 C<sth>
update document
yuki-kimoto authored on 2009-11-19
106

            
cleanup
yuki-kimoto authored on 2010-08-03
107
    my $sth = $query->sth;
108
    $query  = $query->sth($sth);
packaging one directory
yuki-kimoto authored on 2009-11-16
109

            
cleanup
yuki-kimoto authored on 2010-08-05
110
Statement handle of L<DBI>
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
111

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

            
cleanup
yuki-kimoto authored on 2010-08-05
114
L<DBIx::Custom::Query> inherits all methods from L<Object::Simple>.
catch up with Object::Simple...
yuki-kimoto authored on 2010-01-22
115

            
116
=cut