Newer Older
86 lines | 2.078kb
add Oracle, DB2, Pg,
yuki-kimoto authored on 2009-11-16
1
package DBIx::Custom::DB2;
packaging one directory
yuki-kimoto authored on 2009-11-16
2
use base 'DBIx::Custom::Basic';
3

            
4
use warnings;
5
use strict;
6

            
7
my $class = __PACKAGE__;
8

            
9
$class->add_format(
10
    datetime => $class->formats->{SQL99_datetime},
11
    date     => $class->formats->{SQL99_date},
12
    time     => $class->formats->{SQL99_time},
13
);
14

            
15

            
16
sub connect {
17
    my $self = shift;
18
    
19
    if (!$self->data_source && (my $database = $self->database)) {
add Oracle, DB2, Pg,
yuki-kimoto authored on 2009-11-16
20
        $self->data_source("dbi:DB2:dbname=$database");
packaging one directory
yuki-kimoto authored on 2009-11-16
21
    }
22
    
23
    return $self->SUPER::connect;
24
}
25

            
26
=head1 NAME
27

            
add Oracle, DB2, Pg,
yuki-kimoto authored on 2009-11-16
28
DBIx::Custom::DB2 - DBIx::Custom DB2 implementation
packaging one directory
yuki-kimoto authored on 2009-11-16
29

            
30
=head1 Version
31

            
32
Version 0.0102
33

            
34
=head1 Synopsys
35

            
36
    # New
add Oracle, DB2, Pg,
yuki-kimoto authored on 2009-11-16
37
    my $dbi = DBIx::Custom::DB2->new(user => 'taro', $password => 'kliej&@K',
packaging one directory
yuki-kimoto authored on 2009-11-16
38
                                      database => 'sample_db');
39
    # Insert 
40
    $dbi->insert('books', {title => 'perl', author => 'taro'});
41
    
42
    # Update 
43
    # same as 'update books set (title = 'aaa', author = 'ken') where id = 5;
44
    $dbi->update('books', {title => 'aaa', author => 'ken'}, {id => 5});
45
    
46
    # Delete
47
    $dbi->delete('books', {author => 'taro'});
48
    
49
    # select * from books;
50
    $dbi->select('books');
51
    
52
    # select * from books where ahthor = 'taro'; 
53
    $dbi->select('books', {author => 'taro'});
54

            
55
=head1 See DBIx::Custom and DBI::Custom::Basic documentation
56

            
57
This class is L<DBIx::Custom::Basic> subclass,
58
and L<DBIx::Custom::Basic> is L<DBIx::Custom> subclass.
59

            
60
You can use all methods of L<DBIx::Custom::Basic> and <DBIx::Custom>
61
Please see L<DBIx::Custom::Basic> and <DBIx::Custom> documentation.
62

            
63
=head1 Object methods
64

            
65
=head2 connect
66

            
67
    This method override DBIx::Custom::connect
68
    
69
    If database attribute is set, automatically data source is created and connect
70

            
71
=head1 Author
72

            
73
Yuki Kimoto, C<< <kimoto.yuki at gmail.com> >>
74

            
75
Github L<http://github.com/yuki-kimoto>
76

            
77
I develope this module L<http://github.com/yuki-kimoto/DBIx-Custom>
78

            
79
=head1 Copyright & license
80

            
81
Copyright 2009 Yuki Kimoto, all rights reserved.
82

            
83
This program is free software; you can redistribute it and/or modify it
84
under the same terms as Perl itself.
85

            
86