From 954837609d32b1441a7ac8042e8bf639bfe329ee Mon Sep 17 00:00:00 2001 From: fukachan Date: Sun, 5 Aug 2001 12:07:22 +0000 Subject: move main functions to IO::Adapter::SQL::toymodel define fetch_and_cache_address_list() to fetch and cache the array of address list. The main part of get_next_value(). --- fml/lib/IO/Adapter/SQL/toymodel.pm | 66 +++++++++++++++++++++++++++++++------- 1 file changed, 54 insertions(+), 12 deletions(-) (limited to 'fml/lib/IO/Adapter/SQL') diff --git a/fml/lib/IO/Adapter/SQL/toymodel.pm b/fml/lib/IO/Adapter/SQL/toymodel.pm index dc1e926b..8b4cc218 100644 --- a/fml/lib/IO/Adapter/SQL/toymodel.pm +++ b/fml/lib/IO/Adapter/SQL/toymodel.pm @@ -3,7 +3,7 @@ # Copyright (C) 2000,2001 Ken'ichi Fukamachi # All rights reserved. # -# $FML: toymodel.pm,v 1.1.1.1 2001/08/05 01:55:17 fukachan Exp $ +# $FML: toymodel.pm,v 1.2 2001/08/05 03:24:45 fukachan Exp $ # @@ -29,21 +29,63 @@ model. =head1 METHODS -=head2 C +=cut + + +sub add +{ + my ($self, $addr) = @_; + + print STDERR "add( $addr )\n" if $ENV{'debug'}; - $args = { + my $query = $self->_build_sql_query({ query => 'add', - address => 'rudo@nuinui.net', - _params => { - ml_name => 'elena', - file => 'actives', - }, - } + address => $addr, + }); + $self->execute({ query => $query }); +} -=cut +sub delete +{ + my ($self, $addr) = @_; + + print STDERR "delete( $addr )\n" if $ENV{'debug'}; -sub build_sql_query + my $query = $self->_build_sql_query({ + query => 'delete', + address => $addr, + }); + $self->execute({ query => $query }); +} + + +sub fetch_and_cache_address_list +{ + my ($self, $args) = @_; + + my $query = $self->_build_sql_query({ + query => 'get_next_value', + }); + $self->execute({ query => $query }); +} + + +# Descriptions: +# +# $args = { +# query => 'add', +# address => 'rudo@nuinui.net', +# _params => { +# ml_name => 'elena', +# file => 'actives', +# }, +# } +# +# Arguments: $self $args +# Side Effects: +# Return Value: none +sub _build_sql_query { my ($self, $args) = @_; my $query = $args->{ query }; @@ -54,7 +96,7 @@ sub build_sql_query my $file = $self->{ _params }->{ file }; my $table = $self->{ _table }; - print STDERR "build_sql_query( query=$query )\n" if $ENV{'debug'}; + print STDERR "_build_sql_query( query=$query )\n" if $ENV{'debug'}; if ($query eq 'add') { "insert into $table values ('$ml_name', '$file', '$address', 0, 0)"; -- cgit v1.2.1