diff options
| author | fukachan <fukachan> | 2001-03-13 00:52:53 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-03-13 00:52:53 +0000 |
| commit | 100965b3d63445b0a86a178a30d9c4a97c550079 (patch) | |
| tree | 4055795d790855d0bfa3c8d95cf0a0e471fa74a3 /fml/lib | |
| parent | 83d834cc8ff5eefd00c6563c68a64855cbecfec1 (diff) | |
| download | fml8-100965b3d63445b0a86a178a30d9c4a97c550079.tar.gz fml8-100965b3d63445b0a86a178a30d9c4a97c550079.tar.bz2 fml8-100965b3d63445b0a86a178a30d9c4a97c550079.zip | |
prototype of mysql
Diffstat (limited to 'fml/lib')
| -rw-r--r-- | fml/lib/IO/Adapter/RDBMS.pm | 40 | ||||
| -rw-r--r-- | fml/lib/IO/MapAdapter.pm | 9 |
2 files changed, 41 insertions, 8 deletions
diff --git a/fml/lib/IO/Adapter/RDBMS.pm b/fml/lib/IO/Adapter/RDBMS.pm index a21b487e..328af9b2 100644 --- a/fml/lib/IO/Adapter/RDBMS.pm +++ b/fml/lib/IO/Adapter/RDBMS.pm @@ -13,10 +13,9 @@ use strict; use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD); use Carp; - =head1 NAME -IO::Adapter::RDBMS.pm - IO with SQL databases +IO::Adapter::RDBMS - IO with SQL servers =head1 SYNOPSIS @@ -26,15 +25,42 @@ IO::Adapter::RDBMS.pm - IO with SQL databases ... not yet ... +=head1 METHODS + +=head2 C<configure($args)> + +It forwards request to the specified subclass or DBI base class. + + new({ + driver => 'IO::Model::MySQL::toymodel', + }); + =cut -sub new +# Descriptions: configure the detail between SQL servers +# all requests are forwarded to the specified sub-class. +# Arguments: $self $args +# Side Effects: none +# Return Value: subclass object +sub configure { - my ($self) = @_; - my ($type) = ref($self) || $self; - my $me = {}; - return bless $me, $type; + my ($self, $args) = @_; + my $type = $args->{ _type }; + my $schema = $args->{ _schema }; + + $type = 'MySQL' if $type eq 'mysql'; + $type = 'PostgreSQL' if $type eq 'postgresql'; + my $driver = "IO::Adapter::${type}::${schema}"; + + # forward the request to the specified subclass or DBI base class + eval qq{ require $driver; $driver->import();}; + unless ($@) { + @ISA = ($driver); + } + else { + return undef; + } } diff --git a/fml/lib/IO/MapAdapter.pm b/fml/lib/IO/MapAdapter.pm index d4a690dd..8359625e 100644 --- a/fml/lib/IO/MapAdapter.pm +++ b/fml/lib/IO/MapAdapter.pm @@ -120,10 +120,17 @@ sub new $me->{_type} = 'nis.group'; $pkg = 'IO::Adapter::NIS'; } - elsif ($map =~ /(ldap|mysql|postgresql):(\S+)/) { + elsif ($map =~ /(mysql|postgresql):(\S+)/i) { $me->{_type} = $1; $me->{_schema} = $2; $me->{_type} =~ tr/A-Z/a-z/; # lowercase the '_type' syntax + $pkg = 'IO::Adapter::RDBMS'; + } + elsif ($map =~ /(ldap):(\S+)/i) { + $me->{_type} = $1; + $me->{_schema} = $2; + $me->{_type} =~ tr/A-Z/a-z/; # lowercase the '_type' syntax + $pkg = 'IO::Adapter::LDAP'; } else { my $s = "IO::MapAdapter::new: args='$map' is unknown."; |
