数据库搜索的界面和程序
戻る
mscengine_nm.pl
sub mscengine_nm {
my $self = shift;
my(%t,$q,$template,$table,@rec);
# Get CGI query object
$q = $self->query();
$t{html} = $q->param("tmpl");
$t{html} = $t{html} . '.htm';
$template = $self->load_tmpl("$t{html}") || die "error loading tmpl";
$t{title} = $q->param("title");
$t{table} = $q->param("table");
$t{id} = $q->param("id");
$t{item} = $q->param("item");
$t{sth} = $self->dbh->prepare("SELECT id,name FROM $t{table}");
$t{sth}->execute;
while ( @rec = $t{sth}->fetchrow_array ) {
my $row_ref = (); # この初期化はとても重要!
$$row_ref{id} = $rec[0];
$$row_ref{Line} = $rec[1];
push(@loop, $row_ref);
}
$t{sth}->finish;
$template->param(aid => $t{id});
$template->param(title => $t{title});
$template->param(item => $t{item});
$template->param(THIS_LOOP => \@loop);
return $template->output;
}
1;
mscengine_nm.htm
主機の選択
主機の選択
mode:modeengine_nm
aid==>
mscengine_nm1.pl
sub mscengine_nm1 {
my $self = shift;
my(%t,$q,$template,$table,@rec);
# Get CGI query object
$q = $self->query();
$t{html} = $q->param("tmpl");
$t{html} = $t{html} . '.htm';
$template = $self->load_tmpl("$t{html}") || die "error loading tmpl";
$t{title} = $q->param("title");
$t{aid} = $q->param("aid");
$t{id} = $q->param("id");
$t{item} = $q->param("item");
$t{sql} = 'UPDATE main_type1 set ' . $t{item} . ' = "';
$t{sql} .= $t{id} . '" where id = ' . $t{aid};
$t{DO} = $self->dbh->do($t{sql});
$template->param(aid => $t{aid});
$template->param(id => $t{id});
$template->param(sql => $t{sql});
$template->param(DO => $t{DO});
$template->param(title => $t{title});
return $template->output;
}
1;
mscengine_nm1.htm
主機の選択確定
主機の選択確定
mode:modeengine_nm1
aid==>
id==>
sql==>
DO==>
mscs_engine.pl
sub mscs_engine {
my $self = shift;
my(%t,$n,@loop,@rec);
# Get CGI query object
$t{q} = $self->query();
$t{table} = $t{q}->param("table");
$t{item} = $t{q}->param("item");
$t{enq1_id} = $t{q}->param("enq1_id");
$t{word} = $t{q}->param("word1");
$t{word} = lc($t{word});
@loop = ();
$t{NO} = 0;
$t{sth} = $self->dbh->prepare("SELECT id,name FROM $t{table}");
$t{sth}->execute;
while ( @rec = $t{sth}->fetchrow_array ) {
$t{name} = lc($rec[1]);
if ( $t{name} =~ /$t{word}/ ) {
my $row_ref = (); # この初期化はとても重要!
$$row_ref{id} = $rec[0];
$$row_ref{Line} = $rec[1];
push(@loop, $row_ref);
$t{NO}++;
}
}
$t{sth}->finish;
$t{template} = $self->load_tmpl("mscs_engine.htm") || die "error loading tmpl";
if ( $t{NO} == 0 ) {
$t{template}->param(explain => "データはありません。「戻る」をクリック");
} else {
$t{template}->param(explain => "1つを選択してから,「追加」をクリック");
$t{template}->param(THIS_LOOP => \@loop);
}
$t{template}->param(pro => "mscs_engine.pl");
$t{template}->param(table => $t{table});
$t{template}->param(enq1_id => $t{enq1_id});
$t{template}->param(item => $t{item});
return $t{template}->output;
}
1;
mscs_engine.htm
mscs_engine
mode:mscs_engine;Perl:;table:
,
enq1_id==>
item==>
戻る