MySQL操作程序二十六(mscshowtype1.pl)

返回

    修改TYPE的关联程序
  1. mscdatabase.htm的修改(mscenq1.htm中COPY)
  2. 修改mscshowtype1.pl程序(mscs_engine.pl中COPY),首先是没有输入任何内容时的返回
  3. 输入内容时的画面(保存中间数据),利用enq1list的enq1s3和enq1s3_word
  4. 修改完后,返回msc261.htm(注意利用中间数据),msc262.htm的返回部分
  5. msc262.htm修改,mscupdate.pl,msc263.htm/msc263_2.htm修改

sub mscshowtype1 { my $self = shift; my(%t,$n,@arr,@arr1,@loop,@rec); # Get CGI query object $t{q} = $self->query(); # データベースにアクセス $t{table} = $t{q}->param("table"); $t{mode} = $t{q}->param("mode"); @loop = (); if ( $t{mode} eq 'SEARCH') { $t{word} = $t{q}->param("word1"); $t{word} = lc($t{word}); @{ $t{list_id} } = (); $t{NO} = 0; if ( $t{word} ) { $t{sth} = $self->dbh->prepare("SELECT id,name,gname_id,maker_id 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{name} = $rec[1]; $$row_ref{gname_id} = $rec[2]; $$row_ref{maker_id} = $rec[3]; push(@loop, $row_ref); $t{NO}++; push(@{ $t{list_id} },$rec[0]); } } $t{sth}->finish; } $t{template} = $self->load_tmpl("msc261.htm") || die "error loading tmpl"; if ( $t{NO} == 0 ) { $t{template}->param(explain => "没有找到,请返回。"); } else { $t{enq1s3} = join('=',@{ $t{list_id} }); $t{sql1} = 'UPDATE enq1list set enq1s3 = "'; $t{sql1} .= $t{enq1s3} . '" where id = "1"'; $t{DO1} = $self->dbh->do($t{sql1}); $t{word1} = uc($t{word1}); $t{sql1} = 'UPDATE enq1list set enq1s3_word = "'; $t{sql1} .= $t{word} . '" where id = "1"'; $t{DO1} = $self->dbh->do($t{sql1}); $t{template}->param(explain => "找到了如下的TYPE,请选择修改。"); $t{template}->param(THIS_LOOP => \@loop); } } else { $t{enq1s3} = $self->dbh->selectrow_array("SELECT enq1s3 FROM enq1list WHERE enq1s3 != 'NO'"); @{ $t{type1s} } = split(/=/,$t{enq1s3}); for $n ( 0 .. $#{ $t{type1s} } ) { $t{e1_id} = $t{type1s}[$n]; @rec = $self->dbh->selectrow_array("SELECT id,name,gname_id,maker_id FROM main_type1 WHERE id = $t{e1_id}"); my $row_ref = (); # この初期化はとても重要! $$row_ref{id} = $rec[0]; $$row_ref{name} = $rec[1]; $$row_ref{gname_id} = $rec[2]; $$row_ref{maker_id} = $rec[3]; push(@loop, $row_ref); } $t{template} = $self->load_tmpl("msc261.htm") || die "error loading tmpl"; $t{template}->param(THIS_LOOP => \@loop); } return $t{template}->output; } ------------------------------------------------------------- 利用enq1list的enq1s3和enq1s3_word $t{enq1s3} = join('=',@{ $t{list_id} }); $t{sql1} = 'UPDATE enq1list set enq1s3 = "'; $t{sql1} .= $t{enq1s3} . '" where id = "1"'; $t{DO1} = $self->dbh->do($t{sql1}); $t{word1} = uc($t{word1}); $t{sql1} = 'UPDATE enq1list set enq1s3_word = "'; $t{sql1} .= $t{word} . '" where id = "1"'; $t{DO1} = $self->dbh->do($t{sql1}); ------------------------------------------------------------ 新 <form action="" method="post"> <input type=text name=word1 value=""> <input type="submit" value="Equipment Types(main_type1)とパーツデータ修改"><p> <input type="hidden" name="tmpl" value="msc261"> <input type="hidden" name="table" value="main_type1"> <input type="hidden" name="rm" value="modeshowtype1"> </form> 旧 <form action="" method="post"> <input type="submit" value="Equipment Types(main_type1)とパーツデータ"><p> <input type="hidden" name="tmpl" value="msc261"> <input type="hidden" name="table" value="main_type1"> <input type="hidden" name="items" value="id,name,gname_id,maker_id"> <input type="hidden" name="rm" value="modeshowtype1"> </form>
返回