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 register_format()
|
31 |
1; |
32 | ||
packaging one directory
|
33 |
=head1 NAME |
34 | ||
cleanup
|
35 |
DBIx::Custom::MySQL - MySQL implementation |
packaging one directory
|
36 | |
update document
|
37 |
=head1 SYNOPSYS |
packaging one directory
|
38 | |
cleanup
|
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
|
45 |
|
removed DESTROY method(not b...
|
46 |
# Get last insert id |
cleanup
|
47 |
my $last_insert_id = $dbi->last_insert_id; |
packaging one directory
|
48 | |
update document
|
49 |
=head1 ATTRIBUTES |
packaging one directory
|
50 | |
cleanup
|
51 |
L<DBIx::Custom::MySQL> inherits all attributes from L<DBIx::Custom> |
52 |
and implements the following new ones. |
|
packaging one directory
|
53 | |
removed DBIx::Custom commit ...
|
54 |
=head2 C<database> |
packaging one directory
|
55 | |
cleanup
|
56 |
my $database = $dbi->database; |
cleanup
|
57 |
$dbi = $dbi->database('dbname'); |
update document
|
58 | |
removed DESTROY method(not b...
|
59 |
Database name. |
cleanup
|
60 |
C<connect()> method use this value to connect the database |
61 |
if C<data_source> is not specified. |
|
packaging one directory
|
62 | |
removed DESTROY method(not b...
|
63 |
=head2 C<host> |
add Oracle, DB2, Pg,
|
64 | |
cleanup
|
65 |
my $host = $dbi->host; |
cleanup
|
66 |
$dbi = $dbi->host('somehost'); |
update document
|
67 | |
cleanup
|
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
|
71 | |
removed DBIx::Custom commit ...
|
72 |
=head2 C<port> |
update document
|
73 | |
cleanup
|
74 |
my $port = $dbi->port; |
75 |
$dbi = $dbi->port(1198); |
|
update document
|
76 | |
cleanup
|
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...
|
80 | |
update document
|
81 |
=head1 METHODS |
82 | ||
cleanup
|
83 |
L<DBIx::Custom::MySQL> inherits all methods from L<DBIx::Custom> |
84 |
and implements the following new ones. |
|
update document
|
85 | |
cleanup
|
86 |
=head2 C<connect> |
update document
|
87 | |
cleanup
|
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...
|
94 |
); |
update document
|
95 | |
cleanup
|
96 |
Create a new L<DBIx::Custom::MySQL> object and connect to the database. |
cleanup
|
97 |
This method overrides C<DBIx::Custom::connect()> method. |
cleanup
|
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
|
100 | |
update document
|
101 |
=cut |