Newer Older
106 lines | 2.507kb
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

            
deprecated DBIx::Custom::MyS...
root authored on 2010-11-26
37
=head1 CAUTION
38

            
39
B<This module is deprecated now> because This module is not very useful
40
I expected. Please use DBIx::Custom instead.>
41

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

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

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

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

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

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

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

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

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

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

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

            
cleanup
yuki-kimoto authored on 2010-08-03
79
    my $port = $dbi->port;
80
    $dbi     = $dbi->port(1198);
update document
yuki-kimoto authored on 2010-05-27
81

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

            
update document
yuki-kimoto authored on 2010-05-27
86
=head1 METHODS
87

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

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

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

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

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