packaging one directory
|
1 |
package DBIx::Custom::MySQL; |
2 | ||
3 |
use strict; |
|
removed DESTROY method(not b...
|
4 |
use warnings; |
update document
|
5 | |
update document
|
6 |
use base 'DBIx::Custom'; |
7 | ||
8 |
__PACKAGE__->attr([qw/database host port/]); |
|
9 | ||
packaging one directory
|
10 |
sub connect { |
update document
|
11 |
my $proto = shift; |
12 |
|
|
cleanup
|
13 |
# Create a new object |
update document
|
14 |
my $self = ref $proto ? $proto : $proto->new(@_); |
packaging one directory
|
15 |
|
cleanup
|
16 |
# Data source |
add port and host method
|
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
|
26 |
} |
27 |
|
|
28 |
return $self->SUPER::connect; |
|
29 |
} |
|
30 | ||
removed reconnect method
|
31 |
sub last_insert_id { shift->dbh->{mysql_insertid} } |
add Oracle, DB2, Pg,
|
32 | |
removed register_format()
|
33 |
1; |
34 | ||
packaging one directory
|
35 |
=head1 NAME |
36 | ||
cleanup
|
37 |
DBIx::Custom::MySQL - MySQL implementation |
packaging one directory
|
38 | |
update document
|
39 |
=head1 SYNOPSYS |
packaging one directory
|
40 | |
cleanup
|
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
|
47 |
|
removed DESTROY method(not b...
|
48 |
# Get last insert id |
cleanup
|
49 |
my $last_insert_id = $dbi->last_insert_id; |
packaging one directory
|
50 | |
update document
|
51 |
=head1 ATTRIBUTES |
packaging one directory
|
52 | |
cleanup
|
53 |
L<DBIx::Custom::MySQL> inherits all attributes from L<DBIx::Custom> |
54 |
and implements the following new ones. |
|
packaging one directory
|
55 | |
removed DBIx::Custom commit ...
|
56 |
=head2 C<database> |
packaging one directory
|
57 | |
cleanup
|
58 |
my $database = $dbi->database; |
cleanup
|
59 |
$dbi = $dbi->database('dbname'); |
update document
|
60 | |
removed DESTROY method(not b...
|
61 |
Database name. |
cleanup
|
62 |
C<connect()> method use this value to connect the database |
63 |
if C<data_source> is not specified. |
|
packaging one directory
|
64 | |
removed DESTROY method(not b...
|
65 |
=head2 C<host> |
add Oracle, DB2, Pg,
|
66 | |
cleanup
|
67 |
my $host = $dbi->host; |
cleanup
|
68 |
$dbi = $dbi->host('somehost'); |
update document
|
69 | |
cleanup
|
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
|
73 | |
removed DBIx::Custom commit ...
|
74 |
=head2 C<port> |
update document
|
75 | |
cleanup
|
76 |
my $port = $dbi->port; |
77 |
$dbi = $dbi->port(1198); |
|
update document
|
78 | |
cleanup
|
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...
|
82 | |
update document
|
83 |
=head1 METHODS |
84 | ||
cleanup
|
85 |
L<DBIx::Custom::MySQL> inherits all methods from L<DBIx::Custom> |
86 |
and implements the following new ones. |
|
update document
|
87 | |
cleanup
|
88 |
=head2 C<connect> |
update document
|
89 | |
cleanup
|
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...
|
96 |
); |
update document
|
97 | |
cleanup
|
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
|
102 | |
removed DBIx::Custom commit ...
|
103 |
=head2 C<last_insert_id> |
version 0.0901
|
104 | |
cleanup
|
105 |
my $last_insert_id = $dbi->last_insert_id; |
add Oracle, DB2, Pg,
|
106 | |
removed DESTROY method(not b...
|
107 |
Get last insert id. |
cleanup
|
108 |
This is same as C<last_insert_id()> function in MySQL. |
add Oracle, DB2, Pg,
|
109 | |
update document
|
110 |
=cut |