Newer Older
82 lines | 1.786kb
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

            
catch up with Object::Simple...
yuki-kimoto authored on 2010-01-18
10
__PACKAGE__->add_filter(
Simplify key search
yuki-kimoto authored on 2010-02-11
11
    encode_utf8 => sub { encode('UTF-8', $_[0]) },
12
    decode_utf8 => sub { decode('UTF-8', $_[0]) }
packaging one directory
yuki-kimoto authored on 2009-11-16
13
);
14

            
catch up with Object::Simple...
yuki-kimoto authored on 2010-01-18
15
__PACKAGE__->add_format(
packaging one directory
yuki-kimoto authored on 2009-11-16
16
    'SQL99_date'        => '%Y-%m-%d',
17
    'SQL99_datetime'    => '%Y-%m-%d %H:%M:%S',
18
    'SQL99_time'        => '%H:%M:%S',
19
    'ISO-8601_date'     => '%Y-%m-%d',
20
    'ISO-8601_datetime' => '%Y-%m-%dT%H:%M:%S',
21
    'ISO-8601_time'     => '%H:%M:%S',
22
);
23

            
24
1;
25

            
26
=head1 NAME
27

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

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

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

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

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

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

            
46
=head2 encode_utf8
47

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

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

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

            
57
=head2 decode_utf8
58

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

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

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

            
78
You get format as the following
79

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

            
82
=cut