summaryrefslogtreecommitdiff
path: root/fml/lib/IO/Adapter/MySQL
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-03-18 04:40:26 +0000
committerfukachan <fukachan>2001-03-18 04:40:26 +0000
commit5cde1627879fdbb147977caab63e3f339004860b (patch)
tree2b53da62d72e0f780cf3419dd6bb15c322823bed /fml/lib/IO/Adapter/MySQL
parent21047bfa4d80d8d2793c58cd6446252cea88d4d6 (diff)
downloadfml8-5cde1627879fdbb147977caab63e3f339004860b.tar.gz
fml8-5cde1627879fdbb147977caab63e3f339004860b.tar.bz2
fml8-5cde1627879fdbb147977caab63e3f339004860b.zip
modify MySQL adapter interface
move model specific part to SQL::Schema class remove IO::Adapter::MySQL class
Diffstat (limited to 'fml/lib/IO/Adapter/MySQL')
-rw-r--r--fml/lib/IO/Adapter/MySQL/toymodel.pm163
1 files changed, 0 insertions, 163 deletions
diff --git a/fml/lib/IO/Adapter/MySQL/toymodel.pm b/fml/lib/IO/Adapter/MySQL/toymodel.pm
deleted file mode 100644
index 0c3c704f..00000000
--- a/fml/lib/IO/Adapter/MySQL/toymodel.pm
+++ /dev/null
@@ -1,163 +0,0 @@
-#-*- perl -*-
-#
-# Copyright (C) 2000 Ken'ichi Fukamachi
-# All rights reserved.
-#
-# $Id$
-#
-
-
-package IO::Adapter::MySQL::toymodel;
-
-
-use strict;
-use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD);
-use Carp;
-
-=head1 NAME
-
-IO::Adapter::MySQL::toymodel - toymodel with SQL
-
-=head1 SYNOPSIS
-
-=head1 DESCRIPTION
-
-=head1 METHODS
-
-=cut
-
-sub new
-{
- my ($self, $args) = @_;
- my ($type) = ref($self) || $self;
- my $me = {};
-
- $me->{ _ml_name } = $args->{ ml_name };
-
- return bless $me, $type;
-}
-
-
-=head2 C<open($args)>
-
-=head2 C<close($args)>
-
-=cut
-
-
-# Descriptions:
-# Arguments: $self $args
-# Side Effects:
-# Return Value: none
-sub open
-{
- my ($self, $args) = @_;
-
- use DBI;
- use DBD::mysql;
-
- my $driver = 'mysql';
- my $database = $args->{ database_name } || 'fml';
- my $host = $args->{ sql_server } || 'localhost';
- my $dsn = "DBI:$driver:$database:$host";
- my $user = $args->{ sql_user } || 'fml' || '';
- my $password = $args->{ sql_user_password} || '';
-
- my $dbh = DBI->connect($dsn, $user, $password);
- unless (defined $dbh) {
- $args->{'error'} = $DBI::errstr;
- return undef;
- }
-
- $self->{ _dbh } = $dbh;
-}
-
-
-# Descriptions:
-# Arguments: $self $args
-# Side Effects:
-# Return Value: none
-sub close
-{
- my ($self, $args) = @_;
- my $res = $self->{ _res };
- my $dbh = $self->{ _dbh };
-
- $res->finish if defined $res;
- $dbh->disconnect if defined $dbh;
-}
-
-
-=head2 C<getline()>
-
-=cut
-
-
-sub _res_configure
-{
- my ($self, $args) = @_;
-
- unless ($self->{ _res }) {
- my $ml = $self->{ _ml_name };
- my $file = $self->{ _file } || 'members';
- my $query = "select address from ml ";
- $query .= "where ml='$ml' and file='$file' ";
- $self->execute({ query => $query });
- }
-}
-
-
-sub getline
-{
- my ($self, $args) = @_;
- $self->_res_configure($args) unless $self->{ _res };
- my @row = $self->{ _res }->fetchrow_array;
- join(" ", @row);
-}
-
-
-sub get_next_value
-{
- my ($self, $args) = @_;
- $self->_res_configure($args) unless $self->{ _res };
- my @row = $self->{ _res }->fetchrow_array;
- $row[0];
-}
-
-
-=head2 C<execute($args)
-
-execute sql query.
-
- $args->{
- query => sql_query_statment,
- };
-
-=cut
-
-sub execute
-{
- my ($self, $args) = @_;
- my $dbh = $self->{ _dbh };
- my $query = $args->{ query };
-
- if (defined $dbh) {
- my $res = $dbh->prepare($query);
- $res->execute;
-
- unless (defined $res) {
- $self->error_reason( $DBI::errstr );
- return undef;
- }
- else {
- $self->{ _res } = $res;
- return $res;
- }
- }
- else {
- return undef;
- }
-}
-
-
-1;