packaging one directory
|
1 |
package DBIx::Custom::Basic; |
2 | ||
3 |
use warnings; |
|
4 |
use strict; |
|
update document
|
5 | |
6 |
use base 'DBIx::Custom'; |
|
update document
|
7 |
use Encode qw/decode encode/; |
packaging one directory
|
8 | |
catch up with Object::Simple...
|
9 |
__PACKAGE__->add_filter( |
version 0.0901
|
10 |
encode_utf8 => sub { encode('UTF-8', shift) }, |
packaging one directory
|
11 |
decode_utf8 => sub { decode('UTF-8', shift) } |
12 |
); |
|
13 | ||
catch up with Object::Simple...
|
14 |
__PACKAGE__->add_format( |
packaging one directory
|
15 |
'SQL99_date' => '%Y-%m-%d', |
16 |
'SQL99_datetime' => '%Y-%m-%d %H:%M:%S', |
|
17 |
'SQL99_time' => '%H:%M:%S', |
|
18 |
'ISO-8601_date' => '%Y-%m-%d', |
|
19 |
'ISO-8601_datetime' => '%Y-%m-%dT%H:%M:%S', |
|
20 |
'ISO-8601_time' => '%H:%M:%S', |
|
21 |
); |
|
22 | ||
23 |
sub utf8_filter_on { |
|
24 |
my $self = shift; |
|
update document
|
25 |
|
26 |
# Set utf8 filters |
|
packaging one directory
|
27 |
$self->bind_filter($self->filters->{encode_utf8}); |
28 |
$self->fetch_filter($self->filters->{decode_utf8}); |
|
update document
|
29 |
|
30 |
return $self; |
|
packaging one directory
|
31 |
} |
32 | ||
33 |
1; |
|
34 | ||
35 |
=head1 NAME |
|
36 | ||
37 |
DBIx::Custom::Basic - DBIx::Custom basic implementation |
|
38 | ||
update document
|
39 |
=head1 SYNOPSYS |
packaging one directory
|
40 | |
update document
|
41 |
# New |
42 |
my $dbi = DBIx::Custom::Basic->new( |
|
43 |
data_source => "dbi:mysql:database=books", |
|
44 |
user => 'ken', |
|
45 |
password => '!LFKD%$&' |
|
46 |
); |
|
packaging one directory
|
47 | |
update document
|
48 |
=head1 METHODS |
packaging one directory
|
49 | |
update document
|
50 |
This class is L<DBIx::Custom> subclass. |
51 |
You can use all methods of L<DBIx::Custom> |
|
update document
|
52 | |
53 |
=head2 utf8_filter_on |
|
54 | ||
55 |
Encode and decode utf8 filter on |
|
56 | ||
57 |
$dbi->utf8_filter_on; |
|
58 | ||
59 |
This equel to |
|
60 | ||
61 |
$dbi->bind_filter($dbi->filters->{encode_utf8}); |
|
62 |
$dbi->fetch_filter($dbi->filters->{decode_utf8}); |
|
63 | ||
update document
|
64 |
=head1 FILTERS |
packaging one directory
|
65 | |
66 |
=head2 encode_utf8 |
|
67 | ||
version 0.0901
|
68 |
Encode internal string to UTF-8 byte stream |
69 |
If need, utf8::upgrade is also done. |
|
70 | ||
packaging one directory
|
71 |
$dbi->filters->{encode_utf8}->($value); |
72 |
|
|
73 |
This filter is generally used as bind filter |
|
74 | ||
75 |
$dbi->bind_filter($dbi->filters->{encode_utf8}); |
|
76 | ||
77 |
=head2 decode_utf8 |
|
78 | ||
version 0.0901
|
79 |
Decode UTF-8 byte stream to internal string |
packaging one directory
|
80 |
$dbi->filters->{decode_utf8}->($value); |
81 |
|
|
82 |
This filter is generally used as fetch filter |
|
83 | ||
84 |
$dbi->fetch_filter($dbi->filters->{decode_utf8}); |
|
85 | ||
update document
|
86 |
=head1 DATE FORMATS |
packaging one directory
|
87 |
|
88 |
strptime formats is available |
|
89 |
|
|
90 |
# format name format |
|
91 |
'SQL99_date' '%Y-%m-%d', |
|
92 |
'SQL99_datetime' '%Y-%m-%d %H:%M:%S', |
|
93 |
'SQL99_time' '%H:%M:%S', |
|
94 |
'ISO-8601_date' '%Y-%m-%d', |
|
95 |
'ISO-8601_datetime' '%Y-%m-%dT%H:%M:%S', |
|
96 |
'ISO-8601_time' '%H:%M:%S', |
|
97 | ||
98 |
You get format as the following |
|
99 | ||
100 |
my $format = $dbi->formats->{$format_name}; |
|
101 | ||
102 |
=cut |