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