diff options
| author | fukachan <fukachan> | 2001-03-18 10:54:18 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-03-18 10:54:18 +0000 |
| commit | 8bed8a63a670468e298323bb007d80c87a125cd1 (patch) | |
| tree | 308011fad49d007e6b247f9e61821883b7219777 /fml/lib/IO/MapAdapter.pm | |
| parent | 8e2f175842a617de6bb34091ea573d1d6192e001 (diff) | |
| download | fml8-8bed8a63a670468e298323bb007d80c87a125cd1.tar.gz fml8-8bed8a63a670468e298323bb007d80c87a125cd1.tar.bz2 fml8-8bed8a63a670468e298323bb007d80c87a125cd1.zip | |
mysql map can work.
IO::MapAdapter->new() accpets two parameters, $map and the parameters
$map_params.
my $obj = new IO::MapAdapter ('mysql:toymodel', $map_params);
where $map_params = { config => {}, query => {} };
Diffstat (limited to 'fml/lib/IO/MapAdapter.pm')
| -rw-r--r-- | fml/lib/IO/MapAdapter.pm | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/fml/lib/IO/MapAdapter.pm b/fml/lib/IO/MapAdapter.pm index 2179cb2e..1688b910 100644 --- a/fml/lib/IO/MapAdapter.pm +++ b/fml/lib/IO/MapAdapter.pm @@ -23,11 +23,25 @@ IO::MapAdapter - adapter for several IO interfaces =head1 SYNOPSIS use IO::MapAdapter; - $obj = new IO::MapAdapter $map; + $obj = new IO::MapAdapter ($map, $map_params); $obj->open || croak("cannot open $map"); while ($x = $obj->getline) { ... } $obj->close; +where C<$map_params> is map specific parametes used for C<RDBMS>. +For example, C<$map_params> is: + + $map_params = { + 'mysql:toymodel' => { + getline => "select ... ", + get_next_value => "select ... ", + add => "insert ... ", + delete => "delete ... ", + replace => "set address = 'value' where ... ", + }, + }; + + =head1 DESCRIPTION This is "Adapter" (or "Wrapper") C<design pattern>. @@ -96,7 +110,7 @@ sub new { my ($self, $map, $args) = @_; my ($type) = ref($self) || $self; - my ($me) = {}; + my ($me) = { _map => $map }; my $pkg; if (ref($map) eq 'ARRAY') { @@ -125,7 +139,7 @@ sub new $me->{_schema} = $2; $me->{_params} = $args; $me->{_type} =~ tr/A-Z/a-z/; # lowercase the '_type' syntax - $pkg = 'IO::Adapter::RDBMS'; + $pkg = 'IO::Adapter::MySQL'; } elsif ($map =~ /(ldap):(\S+)/i) { $me->{_type} = $1; @@ -145,7 +159,7 @@ sub new @ISA = ($pkg, @ORIG_ISA); eval qq{ require $pkg; $pkg->import();}; - $pkg->configure($me) if $pkg->can('configure'); + $pkg->configure($me, $args) if $pkg->can('configure'); _error_reason($me, $@) if $@; return bless $me, $type; @@ -184,7 +198,7 @@ sub open $self->SUPER::open( { flag => $flag } ); } elsif ($self->{'_type'} =~ /^(ldap|mysql|postgresql)$/o) { - return undef; + $self->SUPER::open( { flag => $flag } ); } else { $self->_error_reason("Error: type=$self->{_type} is unknown type."); |
