summaryrefslogtreecommitdiff
path: root/fml/lib/IO/Adapter/MySQL.pm
diff options
context:
space:
mode:
authorfukachan <fukachan>2005-08-23 08:34:52 +0000
committerfukachan <fukachan>2005-08-23 08:34:52 +0000
commit28918a4875c41bd5620060b71ca61a87f3e5d1b5 (patch)
treeaf615ca747b4c25d13426ad96b28c5317b85ac71 /fml/lib/IO/Adapter/MySQL.pm
parent72fcc4b64bae392d24a81f639e716b1fa39b401a (diff)
downloadfml8-28918a4875c41bd5620060b71ca61a87f3e5d1b5.tar.gz
fml8-28918a4875c41bd5620060b71ca61a87f3e5d1b5.tar.bz2
fml8-28918a4875c41bd5620060b71ca61a87f3e5d1b5.zip
$sql_server -> $sql_servers.
enhanced to handle a list of dsn. fix comments.
Diffstat (limited to 'fml/lib/IO/Adapter/MySQL.pm')
-rw-r--r--fml/lib/IO/Adapter/MySQL.pm39
1 files changed, 27 insertions, 12 deletions
diff --git a/fml/lib/IO/Adapter/MySQL.pm b/fml/lib/IO/Adapter/MySQL.pm
index 263bb86e..bb85e5b4 100644
--- a/fml/lib/IO/Adapter/MySQL.pm
+++ b/fml/lib/IO/Adapter/MySQL.pm
@@ -3,7 +3,7 @@
# Copyright (C) 2000,2001,2002,2003,2004 Ken'ichi Fukamachi
# All rights reserved.
#
-# $FML: MySQL.pm,v 1.27 2004/01/24 09:03:56 fukachan Exp $
+# $FML: MySQL.pm,v 1.28 2004/07/11 15:25:54 fukachan Exp $
#
@@ -30,7 +30,7 @@ IO::Adapter::MySQL - interface to talk with a MySQL server.
my $map = 'mysql:toymodel';
my $map_params = {
$map => {
- sql_server => 'localhost',
+ sql_servers => 'localhost',
user => 'fukachan',
user_password => 'uja',
database => 'fml',
@@ -83,6 +83,7 @@ sub configure
# import variables
for my $key (qw(sql_server
+ sql_servers
sql_database
sql_table
sql_user
@@ -90,15 +91,23 @@ sub configure
$me->{ "_$key" } = $config->{ $key } || '';
}
- use IO::Adapter::DBI;
- my $dsn = IO::Adapter::DBI->make_dsn( {
- driver => 'mysql',
- database => $config->{ sql_database },
- host => $config->{ sql_server },
- });
+ my $host0 = $config->{ sql_server };
+ my $_list = $config->{ sql_servers };
+ my (@array) = split(/\s+/, $_list);
+ my (@hosts) = @array ? (@array) : ( $host0 );
+ my $list = [];
+ for my $host (@hosts) {
+ use IO::Adapter::DBI;
+ my $dsn = IO::Adapter::DBI->make_dsn( {
+ driver => 'mysql',
+ database => $config->{ sql_database },
+ host => $host,
+ });
+ push(@$list, $dsn);
+ }
- # save the current DSN
- $me->{ _dsn } = $dsn;
+ # save the current DSN list (ARRAY_REF).
+ $me->{ _dsn_list } = $list;
# save map specific configuration
$me->{ _config } = $config;
@@ -107,13 +116,15 @@ sub configure
=head2 setpos($pos)
+set position in returned cache.
+
MySQL does not support rollack, so we close and open this transcation.
After re-opening, we moved to the specified $pos.
=cut
-# Descriptions: set position in database handle.
+# Descriptions: set position in returned cache.
# Arguments: OBJ($self) NUM($pos)
# Side Effects: none
# Return Value: none
@@ -142,10 +153,12 @@ sub setpos
=head2 getpos()
+get position in returned cache.
+
=cut
-# Descriptions: get position in database handle.
+# Descriptions: get position in returned cache.
# Arguments: OBJ($self)
# Side Effects: none
# Return Value: NUM
@@ -159,6 +172,8 @@ sub getpos
=head2 eof()
+check if EOF or not?
+
=cut