Newer Older
106 lines | 2.409kb
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
}
22
has  tables => sub { [] };
23

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

            
update document
yuki-kimoto authored on 2010-01-30
66
1;
67

            
packaging one directory
yuki-kimoto authored on 2009-11-16
68
=head1 NAME
69

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

            
72
=head1 SYNOPSIS
73
    
version 0.0901
yuki-kimoto authored on 2009-12-17
74
    my $query = DBIx::Custom::Query->new;
DBIx::Custom::Query filters ...
Yuki Kimoto authored on 2011-07-30
75
    my $sth = $query->sth;
76
    my $sql = $query->sql;
77
    my $columns = $query->columns;
version 0.0901
yuki-kimoto authored on 2009-12-17
78
    
update document
yuki-kimoto authored on 2010-01-30
79
=head1 ATTRIBUTES
packaging one directory
yuki-kimoto authored on 2009-11-16
80

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

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

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

            
cleanup
yuki-kimoto authored on 2010-10-17
88
=head2 C<sql>
89

            
90
    my $sql = $query->sql;
91
    $query  = $query->sql('select * from books where author = ?;');
92

            
93
SQL statement.
94

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

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

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

            
update document
yuki-kimoto authored on 2010-01-30
102
=head1 METHODS
103

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

            
106
=cut