Newer Older
83 lines | 1.83kb
packaging one directory
yuki-kimoto authored on 2009-11-16
1
package DBIx::Custom::Basic;
2

            
3
use warnings;
4
use strict;
update document
yuki-kimoto authored on 2010-01-30
5

            
6
use base 'DBIx::Custom';
Simplify key search
yuki-kimoto authored on 2010-02-11
7

            
update document
yuki-kimoto authored on 2009-11-17
8
use Encode qw/decode encode/;
packaging one directory
yuki-kimoto authored on 2009-11-16
9

            
some changed
yuki-kimoto authored on 2010-05-02
10
__PACKAGE__->register_filter(
many many changes
yuki-kimoto authored on 2010-04-30
11
    none        => sub { $_[0] },
Simplify key search
yuki-kimoto authored on 2010-02-11
12
    encode_utf8 => sub { encode('UTF-8', $_[0]) },
13
    decode_utf8 => sub { decode('UTF-8', $_[0]) }
packaging one directory
yuki-kimoto authored on 2009-11-16
14
);
15

            
some changed
yuki-kimoto authored on 2010-05-02
16
__PACKAGE__->register_format(
packaging one directory
yuki-kimoto authored on 2009-11-16
17
    'SQL99_date'        => '%Y-%m-%d',
18
    'SQL99_datetime'    => '%Y-%m-%d %H:%M:%S',
19
    'SQL99_time'        => '%H:%M:%S',
20
    'ISO-8601_date'     => '%Y-%m-%d',
21
    'ISO-8601_datetime' => '%Y-%m-%dT%H:%M:%S',
22
    'ISO-8601_time'     => '%H:%M:%S',
23
);
24

            
25
1;
26

            
27
=head1 NAME
28

            
29
DBIx::Custom::Basic - DBIx::Custom basic implementation
30

            
update document
yuki-kimoto authored on 2010-01-30
31
=head1 SYNOPSYS
packaging one directory
yuki-kimoto authored on 2009-11-16
32

            
update document
yuki-kimoto authored on 2010-01-30
33
    # New
34
    my $dbi = DBIx::Custom::Basic->new(
35
        data_source => "dbi:mysql:database=books",
36
        user        => 'ken',
37
        password    => '!LFKD%$&'
38
    );
packaging one directory
yuki-kimoto authored on 2009-11-16
39

            
update document
yuki-kimoto authored on 2010-01-30
40
=head1 METHODS
packaging one directory
yuki-kimoto authored on 2009-11-16
41

            
update document
yuki-kimoto authored on 2010-01-30
42
This class is L<DBIx::Custom> subclass.
43
You can use all methods of L<DBIx::Custom>
update document
yuki-kimoto authored on 2009-11-19
44

            
update document
yuki-kimoto authored on 2010-01-30
45
=head1 FILTERS
packaging one directory
yuki-kimoto authored on 2009-11-16
46

            
47
=head2 encode_utf8
48

            
version 0.0901
yuki-kimoto authored on 2009-12-17
49
Encode internal string to UTF-8 byte stream
50
If need, utf8::upgrade is also done.
51

            
packaging one directory
yuki-kimoto authored on 2009-11-16
52
    $dbi->filters->{encode_utf8}->($value);
53
    
54
This filter is generally used as bind filter
55

            
56
    $dbi->bind_filter($dbi->filters->{encode_utf8});
57

            
58
=head2 decode_utf8
59

            
version 0.0901
yuki-kimoto authored on 2009-12-17
60
Decode UTF-8 byte stream to internal string
packaging one directory
yuki-kimoto authored on 2009-11-16
61
    $dbi->filters->{decode_utf8}->($value);
62
    
63
This filter is generally used as fetch filter
64

            
65
    $dbi->fetch_filter($dbi->filters->{decode_utf8});
66

            
Simplify key search
yuki-kimoto authored on 2010-02-11
67
=head1 FORMATS
packaging one directory
yuki-kimoto authored on 2009-11-16
68
    
69
strptime formats is available
70
    
71
    # format name        format
72
    'SQL99_date'         '%Y-%m-%d',
73
    'SQL99_datetime'     '%Y-%m-%d %H:%M:%S',
74
    'SQL99_time'         '%H:%M:%S',
75
    'ISO-8601_date'      '%Y-%m-%d',
76
    'ISO-8601_datetime'  '%Y-%m-%dT%H:%M:%S',
77
    'ISO-8601_time'      '%H:%M:%S',
78

            
79
You get format as the following
80

            
81
    my $format = $dbi->formats->{$format_name};
82

            
83
=cut