packaging one directory
|
1 |
package DBIx::Custom::MySQL; |
2 | ||
3 |
use warnings; |
|
4 |
use strict; |
|
update document
|
5 | |
update document
|
6 |
use base 'DBIx::Custom'; |
7 | ||
add Oracle, DB2, Pg,
|
8 |
use Carp 'croak'; |
packaging one directory
|
9 | |
update document
|
10 |
__PACKAGE__->attr([qw/database host port/]); |
11 | ||
packaging one directory
|
12 |
sub connect { |
update document
|
13 |
my $proto = shift; |
14 |
|
|
15 |
# Create |
|
16 |
my $self = ref $proto ? $proto : $proto->new(@_); |
|
packaging one directory
|
17 |
|
update document
|
18 |
# Create data source |
add port and host method
|
19 |
if (!$self->data_source) { |
20 |
my $database = $self->database; |
|
21 |
my $host = $self->host; |
|
22 |
my $port = $self->port; |
|
23 |
my $data_source = "dbi:mysql:"; |
|
24 |
$data_source .= "database=$database;" if $database; |
|
25 |
$data_source .= "host=$host;" if $host; |
|
26 |
$data_source .= "port=$port;" if $port; |
|
27 |
$self->data_source($data_source); |
|
packaging one directory
|
28 |
} |
29 |
|
|
30 |
return $self->SUPER::connect; |
|
31 |
} |
|
32 | ||
removed reconnect method
|
33 |
sub last_insert_id { shift->dbh->{mysql_insertid} } |
add Oracle, DB2, Pg,
|
34 | |
removed register_format()
|
35 |
1; |
36 | ||
packaging one directory
|
37 |
=head1 NAME |
38 | ||
update document
|
39 |
DBIx::Custom::MySQL - a MySQL implementation of DBIx::Custom |
packaging one directory
|
40 | |
update document
|
41 |
=head1 SYNOPSYS |
packaging one directory
|
42 | |
update document
|
43 |
# Connect |
44 |
my $dbi = DBIx::Custom::MySQL->connect(user => 'taro', |
|
45 |
password => 'kliej&@K', |
|
46 |
database => 'your_database'); |
|
47 |
|
|
48 |
# Last insert id |
|
49 |
my $id = $dbi->last_insert_id; |
|
packaging one directory
|
50 | |
update document
|
51 |
=head1 ATTRIBUTES |
packaging one directory
|
52 | |
update document
|
53 |
This class is L<DBIx::Custom> subclass. |
54 |
You can use all attributes of L<DBIx::Custom> |
|
packaging one directory
|
55 | |
removed DBIx::Custom commit ...
|
56 |
=head2 C<database> |
packaging one directory
|
57 | |
update document
|
58 |
Database name |
update document
|
59 | |
update document
|
60 |
$dbi = $dbi->database('your_database'); |
61 |
$database = $dbi->database; |
|
update document
|
62 | |
removed DBIx::Custom commit ...
|
63 |
=head2 C<host> |
packaging one directory
|
64 | |
update document
|
65 |
Database host name. |
add Oracle, DB2, Pg,
|
66 | |
update document
|
67 |
$dbi = $dbi->host('somehost.com'); |
68 |
$host = $dbi->host; |
|
69 | ||
70 |
IP address can be set to host attribute. |
|
71 | ||
72 |
$dbi->host('127.03.45.12'); |
|
73 | ||
removed DBIx::Custom commit ...
|
74 |
=head2 C<port> |
update document
|
75 | |
76 |
Database port. |
|
77 | ||
78 |
$dbi = $dbi->port(1198); |
|
79 |
$port = $dbi->port; |
|
80 | ||
81 |
=head1 METHODS |
|
82 | ||
83 |
This class is L<DBIx::Custom> subclass. |
|
84 |
You can use all methods of L<DBIx::Custom>. |
|
85 | ||
removed DBIx::Custom commit ...
|
86 |
=head2 C<connect (overridden)> |
update document
|
87 | |
88 |
Connect to database. |
|
89 | ||
90 |
# Connect |
|
91 |
my $dbi = DBIx::Custom::MySQL->connect(user => 'taro', |
|
92 |
password => 'kliej&@K', |
|
93 |
database => 'your_database'); |
|
94 | ||
removed DBIx::Custom commit ...
|
95 |
=head2 C<last_insert_id> |
version 0.0901
|
96 | |
update document
|
97 |
Last insert ID. |
version 0.0901
|
98 | |
update document
|
99 |
$last_insert_id = $dbi->last_insert_id; |
add Oracle, DB2, Pg,
|
100 | |
update document
|
101 |
This is equal to MySQL last_insert_id() function. |
add Oracle, DB2, Pg,
|
102 | |
103 |
|
|
update document
|
104 |
=cut |