packing
|
1 |
package DBIx::Custom::MySQL; |
2 |
use base 'DBIx::Custom::Basic'; |
|
3 | ||
4 |
use warnings; |
|
5 |
use strict; |
|
Various change
|
6 |
our $VERSION = '0.0102'; |
packing
|
7 | |
8 |
my $class = __PACKAGE__; |
|
9 | ||
10 |
$class->add_format( |
|
11 |
datetime => $class->formats->{SQL99_datetime}, |
|
12 |
date => $class->formats->{SQL99_date}, |
|
13 |
time => $class->formats->{SQL99_time}, |
|
14 |
); |
|
15 | ||
16 | ||
17 |
sub connect { |
|
18 |
my $self = shift; |
|
19 |
|
|
20 |
if (!$self->data_source && (my $database = $self->database)) { |
|
21 |
$self->data_source("dbi:mysql:dbname=$database"); |
|
22 |
} |
|
23 |
|
|
24 |
return $self->SUPER::connect; |
|
25 |
} |
|
26 | ||
27 |
=head1 NAME |
|
28 | ||
29 |
DBIx::Custom::MySQL - DBIx::Custom MySQL implementation |
|
30 | ||
Various change
|
31 |
=head1 Version |
packing
|
32 | |
Various change
|
33 |
Version 0.0102 |
packing
|
34 | |
Various change
|
35 |
=head1 Synopsys |
packing
|
36 | |
37 |
# New |
|
38 |
my $dbi = DBIx::Custom::MySQL->new(user => 'taro', $password => 'kliej&@K', |
|
39 |
database => 'sample_db'); |
|
40 |
# Insert |
|
41 |
$dbi->insert('books', {title => 'perl', author => 'taro'}); |
|
42 |
|
|
43 |
# Update |
|
44 |
# same as 'update books set (title = 'aaa', author = 'ken') where id = 5; |
|
45 |
$dbi->update('books', {title => 'aaa', author => 'ken'}, {id => 5}); |
|
46 |
|
|
47 |
# Delete |
|
48 |
$dbi->delete('books', {author => 'taro'}); |
|
49 |
|
|
50 |
# select * from books; |
|
51 |
$dbi->select('books'); |
|
52 |
|
|
53 |
# select * from books where ahthor = 'taro'; |
|
54 |
$dbi->select('books', {author => 'taro'}); |
|
55 | ||
Various change
|
56 |
=head1 See DBIx::Custom and DBI::Custom::Basic documentation |
packing
|
57 | |
Various change
|
58 |
This class is L<DBIx::Custom::Basic> subclass, |
59 |
and L<DBIx::Custom::Basic> is L<DBIx::Custom> subclass. |
|
60 | ||
61 |
You can use all methods of L<DBIx::Custom::Basic> and <DBIx::Custom> |
|
62 |
Please see L<DBIx::Custom::Basic> and <DBIx::Custom> documentation. |
|
packing
|
63 | |
Various change
|
64 |
=head1 Object methods |
packing
|
65 | |
66 |
=head2 connect |
|
67 | ||
68 |
This method override DBIx::Custom::connect |
|
69 |
|
|
Various change
|
70 |
If database attribute is set, automatically data source is created and connect |
packing
|
71 | |
Various change
|
72 |
=head1 Author |
packing
|
73 | |
74 |
Yuki Kimoto, C<< <kimoto.yuki at gmail.com> >> |
|
75 | ||
76 |
Github L<http://github.com/yuki-kimoto> |
|
77 | ||
Various change
|
78 |
I develope this module L<http://github.com/yuki-kimoto/DBIx-Custom> |
79 | ||
80 |
=head1 Copyright & license |
|
packing
|
81 | |
82 |
Copyright 2009 Yuki Kimoto, all rights reserved. |
|
83 | ||
84 |
This program is free software; you can redistribute it and/or modify it |
|
85 |
under the same terms as Perl itself. |
|
86 | ||
87 |