Newer Older
101 lines | 2.372kb
packaging one directory
yuki-kimoto authored on 2009-11-16
1
package DBIx::Custom::MySQL;
2

            
3
use strict;
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
4
use warnings;
update document
yuki-kimoto authored on 2010-01-30
5

            
update document
yuki-kimoto authored on 2010-05-27
6
use base 'DBIx::Custom';
7

            
8
__PACKAGE__->attr([qw/database host port/]);
9

            
packaging one directory
yuki-kimoto authored on 2009-11-16
10
sub connect {
update document
yuki-kimoto authored on 2010-05-27
11
    my $proto = shift;
12
    
cleanup
yuki-kimoto authored on 2010-08-05
13
    # Create a new object
update document
yuki-kimoto authored on 2010-05-27
14
    my $self = ref $proto ? $proto : $proto->new(@_);
packaging one directory
yuki-kimoto authored on 2009-11-16
15
    
cleanup
yuki-kimoto authored on 2010-08-05
16
    # Data source
add port and host method
yuki-kimoto authored on 2009-11-16
17
    if (!$self->data_source) {
18
        my $database = $self->database;
19
        my $host     = $self->host;
20
        my $port     = $self->port;
21
        my $data_source = "dbi:mysql:";
22
        $data_source .= "database=$database;" if $database;
23
        $data_source .= "host=$host;"         if $host;
24
        $data_source .= "port=$port;"         if $port;
25
        $self->data_source($data_source);
packaging one directory
yuki-kimoto authored on 2009-11-16
26
    }
27
    
28
    return $self->SUPER::connect;
29
}
30

            
removed register_format()
yuki-kimoto authored on 2010-05-26
31
1;
32

            
packaging one directory
yuki-kimoto authored on 2009-11-16
33
=head1 NAME
34

            
cleanup
yuki-kimoto authored on 2010-08-03
35
DBIx::Custom::MySQL - MySQL implementation
packaging one directory
yuki-kimoto authored on 2009-11-16
36

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

            
cleanup
yuki-kimoto authored on 2010-08-05
39
    # Connect to the database
40
    my $dbi = DBIx::Custom::MySQL->connect(
41
        user     => 'taro', 
42
        password => 'kliej&@K',
43
        database => 'dbname'
44
    );
update document
yuki-kimoto authored on 2010-05-27
45
    
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
46
    # Get last insert id
cleanup
yuki-kimoto authored on 2010-08-05
47
    my $last_insert_id = $dbi->last_insert_id;
packaging one directory
yuki-kimoto authored on 2009-11-16
48

            
update document
yuki-kimoto authored on 2010-05-27
49
=head1 ATTRIBUTES
packaging one directory
yuki-kimoto authored on 2009-11-16
50

            
cleanup
yuki-kimoto authored on 2010-08-05
51
L<DBIx::Custom::MySQL> inherits all attributes from L<DBIx::Custom>
52
and implements the following new ones.
packaging one directory
yuki-kimoto authored on 2009-11-16
53

            
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
54
=head2 C<database>
packaging one directory
yuki-kimoto authored on 2009-11-16
55

            
cleanup
yuki-kimoto authored on 2010-08-03
56
    my $database = $dbi->database;
cleanup
yuki-kimoto authored on 2010-08-05
57
    $dbi         = $dbi->database('dbname');
update document
yuki-kimoto authored on 2009-11-19
58

            
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
59
Database name.
cleanup
yuki-kimoto authored on 2010-08-05
60
C<connect()> method use this value to connect the database
61
if C<data_source> is not specified.
packaging one directory
yuki-kimoto authored on 2009-11-16
62

            
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
63
=head2 C<host>
add Oracle, DB2, Pg,
yuki-kimoto authored on 2009-11-16
64

            
cleanup
yuki-kimoto authored on 2010-08-03
65
    my $host = $dbi->host;
cleanup
yuki-kimoto authored on 2010-08-05
66
    $dbi     = $dbi->host('somehost');
update document
yuki-kimoto authored on 2010-05-27
67

            
cleanup
yuki-kimoto authored on 2010-08-05
68
Host name or IP address.
69
C<connect()> method use this value to connect the database
70
if C<data_source> is not specified.
update document
yuki-kimoto authored on 2010-05-27
71

            
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
72
=head2 C<port>
update document
yuki-kimoto authored on 2010-05-27
73

            
cleanup
yuki-kimoto authored on 2010-08-03
74
    my $port = $dbi->port;
75
    $dbi     = $dbi->port(1198);
update document
yuki-kimoto authored on 2010-05-27
76

            
cleanup
yuki-kimoto authored on 2010-08-05
77
Port number.
78
C<connect()> method use this value to connect the database
79
if C<data_source> is not specified.
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
80

            
update document
yuki-kimoto authored on 2010-05-27
81
=head1 METHODS
82

            
cleanup
yuki-kimoto authored on 2010-08-05
83
L<DBIx::Custom::MySQL> inherits all methods from L<DBIx::Custom>
84
and implements the following new ones.
update document
yuki-kimoto authored on 2010-05-27
85

            
cleanup
yuki-kimoto authored on 2010-08-05
86
=head2 C<connect>
update document
yuki-kimoto authored on 2010-05-27
87

            
cleanup
yuki-kimoto authored on 2010-08-05
88
    my $dbi = DBIx::Custom::MySQL->connect(
89
         user     => 'taro', 
90
         password => 'kliej&@K',
91
         database => 'dbname',
92
         host     => 'somehost',
93
         port     => 2000
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
94
    );
update document
yuki-kimoto authored on 2010-05-27
95

            
cleanup
yuki-kimoto authored on 2010-08-05
96
Create a new L<DBIx::Custom::MySQL> object and connect to the database.
cleanup
yuki-kimoto authored on 2010-08-05
97
This method overrides C<DBIx::Custom::connect()> method.
cleanup
yuki-kimoto authored on 2010-08-05
98
You can specify all attributes of L<DBIx::Custom>
99
and L<DBIx::Custom::MySQL>, such as C<database>, C<host>, C<port>.
update document
yuki-kimoto authored on 2010-05-27
100

            
update document
yuki-kimoto authored on 2010-01-30
101
=cut