Newer Older
110 lines | 2.574kb
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 reconnect method
yuki-kimoto authored on 2010-05-28
31
sub last_insert_id { shift->dbh->{mysql_insertid} }
add Oracle, DB2, Pg,
yuki-kimoto authored on 2009-11-16
32

            
removed register_format()
yuki-kimoto authored on 2010-05-26
33
1;
34

            
packaging one directory
yuki-kimoto authored on 2009-11-16
35
=head1 NAME
36

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
update document
yuki-kimoto authored on 2010-05-27
83
=head1 METHODS
84

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

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

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

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

            
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
103
=head2 C<last_insert_id>
version 0.0901
yuki-kimoto authored on 2009-12-17
104

            
cleanup
yuki-kimoto authored on 2010-08-05
105
    my $last_insert_id = $dbi->last_insert_id;
add Oracle, DB2, Pg,
yuki-kimoto authored on 2009-11-16
106

            
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
107
Get last insert id.
cleanup
yuki-kimoto authored on 2010-08-05
108
This is same as C<last_insert_id()> function in MySQL.
add Oracle, DB2, Pg,
yuki-kimoto authored on 2009-11-16
109

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