summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-08-05 01:55:17 +0000
committerfukachan <fukachan>2001-08-05 01:55:17 +0000
commit72fa1d5d9fc98dda148bd0b4e93a4647528b4dd8 (patch)
tree61febe04d74a07c79dc96baa14011dafb95dd647
parenta5e69b8227d0918f554fa83b476ace8cf1834b7d (diff)
downloadfml8-snap-20010805.tar.gz
fml8-snap-20010805.tar.bz2
fml8-snap-20010805.zip
move SQL::Schema:: to heresnap-20010805
-rw-r--r--fml/lib/IO/Adapter/SQL/toymodel.pm71
1 files changed, 71 insertions, 0 deletions
diff --git a/fml/lib/IO/Adapter/SQL/toymodel.pm b/fml/lib/IO/Adapter/SQL/toymodel.pm
new file mode 100644
index 00000000..e9b638ec
--- /dev/null
+++ b/fml/lib/IO/Adapter/SQL/toymodel.pm
@@ -0,0 +1,71 @@
+#-*- perl -*-
+#
+# Copyright (C) 2000,2001 Ken'ichi Fukamachi
+# All rights reserved.
+#
+# $FML: toymodel.pm,v 1.6 2001/06/17 08:57:11 fukachan Exp $
+#
+
+
+package SQL::Schema::toymodel;
+
+use strict;
+use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD);
+use Carp;
+
+=head1 NAME
+
+SQL::Schema::toymodel - SQL statement dependent on toymodel
+
+=head1 SYNOPSIS
+
+ use SQL::Schema::toymodel;
+ $obj = new SQL::Schema::toymodel;
+
+=head1 DESCRIPTION
+
+SQL::Schema modules hold SQL statement dependent on each specific
+model.
+
+=head1 METHODS
+
+=head2 C<build_sql_query($args)>
+
+ $args = {
+ query => 'add',
+ address => 'rudo@nuinui.net',
+ _params => {
+ ml_name => 'elena',
+ file => 'actives',
+ },
+ }
+
+=cut
+
+
+sub build_sql_query
+{
+ my ($self, $args) = @_;
+ my $query = $args->{ query };
+ my $address = $args->{ address };
+
+ # inherit parameter from object
+ my $ml_name = $self->{ _params }->{ ml_name };
+ my $file = $self->{ _params }->{ file };
+ my $table = $self->{ _table };
+
+ 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)";
+ }
+ elsif ($query eq 'delete') {
+ "delete from $table where ml='$ml_name' and address='$address'";
+ }
+ else {
+ "select address from $table where ml='$ml_name' and file='$file'";
+ }
+}
+
+
+1;