blob: e9b638ec032ef8679e33bd30164fa8abea4b454f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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;
|