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 |
|
|
13 |
# Create |
|
14 |
my $self = ref $proto ? $proto : $proto->new(@_); |
|
packaging one directory
|
15 |
|
update document
|
16 |
# Create 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 | |
removed DESTROY method(not b...
|
41 |
# Connect to database |
42 |
my $dbi = DBIx::Custom::MySQL->connect(user => 'taro', |
|
update document
|
43 |
password => 'kliej&@K', |
removed DESTROY method(not b...
|
44 |
database => 'your_database'); |
update document
|
45 |
|
removed DESTROY method(not b...
|
46 |
# Get last insert id |
update document
|
47 |
my $id = $dbi->last_insert_id; |
packaging one directory
|
48 | |
update document
|
49 |
=head1 ATTRIBUTES |
packaging one directory
|
50 | |
update document
|
51 |
This class is L<DBIx::Custom> subclass. |
52 |
You can use all attributes of L<DBIx::Custom> |
|
packaging one directory
|
53 | |
removed DBIx::Custom commit ...
|
54 |
=head2 C<database> |
packaging one directory
|
55 | |
cleanup
|
56 |
my $database = $dbi->database; |
57 |
$dbi = $dbi->database('your_database'); |
|
update document
|
58 | |
removed DESTROY method(not b...
|
59 |
Database name. |
60 |
This is used for connect(). |
|
packaging one directory
|
61 | |
removed DESTROY method(not b...
|
62 |
=head2 C<host> |
add Oracle, DB2, Pg,
|
63 | |
cleanup
|
64 |
my $host = $dbi->host; |
65 |
$dbi = $dbi->host('somehost.com'); |
|
update document
|
66 | |
removed DESTROY method(not b...
|
67 |
Database host name. |
68 |
You can also set IP address, instead of host name. |
|
69 |
This is used for connect(). |
|
update document
|
70 | |
71 |
$dbi->host('127.03.45.12'); |
|
72 | ||
removed DBIx::Custom commit ...
|
73 |
=head2 C<port> |
update document
|
74 | |
cleanup
|
75 |
my $port = $dbi->port; |
76 |
$dbi = $dbi->port(1198); |
|
update document
|
77 | |
removed DESTROY method(not b...
|
78 |
Database port. This is used for connect(). |
79 | ||
update document
|
80 |
=head1 METHODS |
81 | ||
82 |
This class is L<DBIx::Custom> subclass. |
|
83 |
You can use all methods of L<DBIx::Custom>. |
|
84 | ||
removed DBIx::Custom commit ...
|
85 |
=head2 C<connect (overridden)> |
update document
|
86 | |
removed DESTROY method(not b...
|
87 |
$dbi = DBIx::Custom::MySQL->connect( |
88 |
data_source => "dbi:mysql:database=books;host=somehost;port=2000" |
|
89 |
); |
|
90 |
|
|
91 |
$dbi = DBIx::Custom::MySQL->connect(user => 'taro', |
|
92 |
password => 'kliej&@K', |
|
93 |
database => 'your_database', |
|
94 |
host => 'somehost', |
|
95 |
port => 2000); |
|
update document
|
96 | |
removed DESTROY method(not b...
|
97 |
Connect to database. You can also specify database, host, and port |
98 |
(instead of data soruce). |
|
update document
|
99 | |
removed DBIx::Custom commit ...
|
100 |
=head2 C<last_insert_id> |
version 0.0901
|
101 | |
update document
|
102 |
$last_insert_id = $dbi->last_insert_id; |
add Oracle, DB2, Pg,
|
103 | |
removed DESTROY method(not b...
|
104 |
Get last insert id. |
update document
|
105 |
This is equal to MySQL last_insert_id() function. |
add Oracle, DB2, Pg,
|
106 | |
update document
|
107 |
=cut |