| ... | ... |
@@ -10,10 +10,10 @@ __PACKAGE__->attr([qw/database host port/]); |
| 10 | 10 |
sub connect {
|
| 11 | 11 |
my $proto = shift; |
| 12 | 12 |
|
| 13 |
- # Create |
|
| 13 |
+ # Create a new object |
|
| 14 | 14 |
my $self = ref $proto ? $proto : $proto->new(@_); |
| 15 | 15 |
|
| 16 |
- # Create data source |
|
| 16 |
+ # Data source |
|
| 17 | 17 |
if (!$self->data_source) {
|
| 18 | 18 |
my $database = $self->database; |
| 19 | 19 |
my $host = $self->host; |
| ... | ... |
@@ -38,70 +38,73 @@ DBIx::Custom::MySQL - MySQL implementation |
| 38 | 38 |
|
| 39 | 39 |
=head1 SYNOPSYS |
| 40 | 40 |
|
| 41 |
- # Connect to database |
|
| 42 |
- my $dbi = DBIx::Custom::MySQL->connect(user => 'taro', |
|
| 43 |
- password => 'kliej&@K', |
|
| 44 |
- database => 'your_database'); |
|
| 41 |
+ # Connect to the database |
|
| 42 |
+ my $dbi = DBIx::Custom::MySQL->connect( |
|
| 43 |
+ user => 'taro', |
|
| 44 |
+ password => 'kliej&@K', |
|
| 45 |
+ database => 'dbname' |
|
| 46 |
+ ); |
|
| 45 | 47 |
|
| 46 | 48 |
# Get last insert id |
| 47 |
- my $id = $dbi->last_insert_id; |
|
| 49 |
+ my $last_insert_id = $dbi->last_insert_id; |
|
| 48 | 50 |
|
| 49 | 51 |
=head1 ATTRIBUTES |
| 50 | 52 |
|
| 51 |
-This class is L<DBIx::Custom> subclass. |
|
| 52 |
-You can use all attributes of L<DBIx::Custom> |
|
| 53 |
+L<DBIx::Custom::MySQL> inherits all attributes from L<DBIx::Custom> |
|
| 54 |
+and implements the following new ones. |
|
| 53 | 55 |
|
| 54 | 56 |
=head2 C<database> |
| 55 | 57 |
|
| 56 | 58 |
my $database = $dbi->database; |
| 57 |
- $dbi = $dbi->database('your_database');
|
|
| 59 |
+ $dbi = $dbi->database('dbname');
|
|
| 58 | 60 |
|
| 59 | 61 |
Database name. |
| 60 |
-This is used for connect(). |
|
| 62 |
+C<connect()> method use this value to connect the database |
|
| 63 |
+if C<data_source> is not specified. |
|
| 61 | 64 |
|
| 62 | 65 |
=head2 C<host> |
| 63 | 66 |
|
| 64 | 67 |
my $host = $dbi->host; |
| 65 |
- $dbi = $dbi->host('somehost.com');
|
|
| 66 |
- |
|
| 67 |
-Database host name. |
|
| 68 |
-You can also set IP address, instead of host name. |
|
| 69 |
-This is used for connect(). |
|
| 68 |
+ $dbi = $dbi->host('somehost');
|
|
| 70 | 69 |
|
| 71 |
- $dbi->host('127.03.45.12');
|
|
| 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. |
|
| 72 | 73 |
|
| 73 | 74 |
=head2 C<port> |
| 74 | 75 |
|
| 75 | 76 |
my $port = $dbi->port; |
| 76 | 77 |
$dbi = $dbi->port(1198); |
| 77 | 78 |
|
| 78 |
-Database port. This is used for connect(). |
|
| 79 |
+Port number. |
|
| 80 |
+C<connect()> method use this value to connect the database |
|
| 81 |
+if C<data_source> is not specified. |
|
| 79 | 82 |
|
| 80 | 83 |
=head1 METHODS |
| 81 | 84 |
|
| 82 |
-This class is L<DBIx::Custom> subclass. |
|
| 83 |
-You can use all methods of L<DBIx::Custom>. |
|
| 85 |
+L<DBIx::Custom::MySQL> inherits all methods from L<DBIx::Custom> |
|
| 86 |
+and implements the following new ones. |
|
| 84 | 87 |
|
| 85 |
-=head2 C<connect (overridden)> |
|
| 88 |
+=head2 C<connect> |
|
| 86 | 89 |
|
| 87 |
- $dbi = DBIx::Custom::MySQL->connect( |
|
| 88 |
- data_source => "dbi:mysql:database=books;host=somehost;port=2000" |
|
| 90 |
+ my $dbi = DBIx::Custom::MySQL->connect( |
|
| 91 |
+ user => 'taro', |
|
| 92 |
+ password => 'kliej&@K', |
|
| 93 |
+ database => 'dbname', |
|
| 94 |
+ host => 'somehost', |
|
| 95 |
+ port => 2000 |
|
| 89 | 96 |
); |
| 90 |
- |
|
| 91 |
- $dbi = DBIx::Custom::MySQL->connect(user => 'taro', |
|
| 92 |
- password => 'kliej&@K', |
|
| 93 |
- database => 'your_database', |
|
| 94 |
- host => 'somehost', |
|
| 95 |
- port => 2000); |
|
| 96 | 97 |
|
| 97 |
-Connect to database. You can also specify database, host, and port |
|
| 98 |
-(instead of data soruce). |
|
| 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>. |
|
| 99 | 102 |
|
| 100 | 103 |
=head2 C<last_insert_id> |
| 101 | 104 |
|
| 102 |
- $last_insert_id = $dbi->last_insert_id; |
|
| 105 |
+ my $last_insert_id = $dbi->last_insert_id; |
|
| 103 | 106 |
|
| 104 | 107 |
Get last insert id. |
| 105 |
-This is equal to MySQL last_insert_id() function. |
|
| 108 |
+This is same as C<last_insert_id()> function in MySQL. |
|
| 106 | 109 |
|
| 107 | 110 |
=cut |
| ... | ... |
@@ -77,7 +77,7 @@ and implements the following new ones. |
| 77 | 77 |
|
| 78 | 78 |
my $dbi = DBIx::Custom::SQLite->connect(database => 'dbname'); |
| 79 | 79 |
|
| 80 |
-Create a new L<DBIx::Custom::SQLite> object and connect to database. |
|
| 80 |
+Create a new L<DBIx::Custom::SQLite> object and connect to the database. |
|
| 81 | 81 |
This method override C<DBIx::Custom::connect()> method. |
| 82 | 82 |
You can specify all attributes of L<DBIx::Custom> |
| 83 | 83 |
and L<DBIx::Custom::SQLite>, such as C<database>. |