Newer Older
75 lines | 1.893kb
add Oracle, DB2, Pg,
yuki-kimoto authored on 2009-11-16
1
package DBIx::Custom::Oracle;
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
sub connect {
10
    my $self = shift;
11
    
12
    if (!$self->data_source && (my $database = $self->database)) {
add Oracle, DB2, Pg,
yuki-kimoto authored on 2009-11-16
13
        $self->data_source("dbi:Oracle:dbname=$database");
packaging one directory
yuki-kimoto authored on 2009-11-16
14
    }
15
    
16
    return $self->SUPER::connect;
17
}
18

            
19
=head1 NAME
20

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

            
23
=head1 Synopsys
24

            
25
    # New
add Oracle, DB2, Pg,
yuki-kimoto authored on 2009-11-16
26
    my $dbi = DBIx::Custom::Oracle->new(user => 'taro', $password => 'kliej&@K',
27
                                        database => 'sample_db');
packaging one directory
yuki-kimoto authored on 2009-11-16
28
    # Insert 
29
    $dbi->insert('books', {title => 'perl', author => 'taro'});
30
    
31
    # Update 
32
    # same as 'update books set (title = 'aaa', author = 'ken') where id = 5;
33
    $dbi->update('books', {title => 'aaa', author => 'ken'}, {id => 5});
34
    
35
    # Delete
36
    $dbi->delete('books', {author => 'taro'});
37
    
38
    # select * from books;
39
    $dbi->select('books');
40
    
41
    # select * from books where ahthor = 'taro'; 
42
    $dbi->select('books', {author => 'taro'});
43

            
44
=head1 See DBIx::Custom and DBI::Custom::Basic documentation
45

            
46
This class is L<DBIx::Custom::Basic> subclass,
47
and L<DBIx::Custom::Basic> is L<DBIx::Custom> subclass.
48

            
49
You can use all methods of L<DBIx::Custom::Basic> and <DBIx::Custom>
50
Please see L<DBIx::Custom::Basic> and <DBIx::Custom> documentation.
51

            
52
=head1 Object methods
53

            
54
=head2 connect
55

            
56
    This method override DBIx::Custom::connect
57
    
58
    If database attribute is set, automatically data source is created and connect
59

            
60
=head1 Author
61

            
62
Yuki Kimoto, C<< <kimoto.yuki at gmail.com> >>
63

            
64
Github L<http://github.com/yuki-kimoto>
65

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

            
68
=head1 Copyright & license
69

            
70
Copyright 2009 Yuki Kimoto, all rights reserved.
71

            
72
This program is free software; you can redistribute it and/or modify it
73
under the same terms as Perl itself.
74

            
75