MySQL操作程序三十四(mscshow241.pl,mscshowaddowner.pl,mscupdate.pl,msc241_list)
返回
owners生成和修改时,项目的增加
- mscshowaddowner.pl
- msc241.pl
[Mon Apr 16 10:00:08 2012] [error] [client 192.168.116.107] DBD::mysql::db selectrow_array failed: Unknown column 'B' in 'where clause' at ./pro/mscshow241.pl line 59
[Mon Apr 16 10:00:08 2012] [error] [client 192.168.116.107] Use of uninitialized value in join or string at ./pro/mscshow241.pl line 62
for $n ( 0 .. $#{ $t{type1s} } ) {
$t{type1s1} = $t{type1s}[$n];
59: $t{name1} = $self->dbh->selectrow_array("SELECT name FROM main_type1 WHERE id = $t{type1s1}");
60: push(@{ $t{type1} },$t{name1});
61: }
62: $t{type1_list} = join('
',@{ $t{type1} });
解决方法:
当type1s1是'B'的时候,不去读main_type1表
- msc241_list的界面直接点击OURREF后到ENQ画面
mscenq1_start.pl,mscenq1_start1.htm参考
- 把owners的name改成name1
修改相应的界面文件,mscdatabase.htm,msc241.htm,msc242.htm,msc243.htm,msc241_list.htm
- owners,id=279更新时出错,msc242,加了顾客代号即可
检查mscupdate.pl程序,更新操作的数据问题
发现一个大问题,有其他table用了"name"这个item!!!
需要把owners的name改名!
===>
--------------------------------------------------------------------------
HTML::Template : Attempt to set nonexistent parameter 'name1' - this parameter
name doesn't match any declarations in the template file : (die_on_bad_params
=> 1) at ./pro/mscshowone.pl line 41
==>msc242.htm忘了修改
mysql> ALTER TABLE owners CHANGE name name1 char(100);
Query OK, 331 rows affected (1.39 sec)
Records: 331 Duplicates: 0 Warnings: 0
mysql> show columns from owners;
+----------+-----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+-----------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| company | char(100) | YES | | NULL | |
| name1 | char(100) | YES | | NULL | |
| address | char(100) | YES | | NULL | |
| person | char(50) | YES | | NULL | |
| telfax | char(100) | YES | | NULL | |
| email | char(100) | YES | | NULL | |
| homepage | char(100) | YES | | NULL | |
| memo | char(100) | YES | | NULL | |
+----------+-----------+------+-----+---------+----------------+
9 rows in set (0.01 sec)
mysql> show columns from hull_no;
+---------+-----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+-----------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| HULL_NO | char(50) | YES | | NULL | |
| name | char(50) | YES | | NULL | |
| built | date | YES | | NULL | |
| flag | char(50) | YES | | NULL | |
| memo | char(100) | YES | | NULL | |
+---------+-----------+------+-----+---------+----------------+
6 rows in set (0.13 sec)
mysql> show columns from owners;
+----------+-----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+-----------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| company | char(100) | YES | | NULL | |
| name | char(100) | YES | | NULL | |
| address | char(100) | YES | | NULL | |
| person | char(50) | YES | | NULL | |
| telfax | char(100) | YES | | NULL | |
| email | char(100) | YES | | NULL | |
| homepage | char(100) | YES | | NULL | |
| memo | char(100) | YES | | NULL | |
+----------+-----------+------+-----+---------+----------------+
9 rows in set (0.09 sec)
mscupdate.pl
# 入力したname
if ( $arr[1] eq 'name' && $t{table} ne "main_type1" ) {
$t{name1} = $t{q}->param($arr[1]);
# すべてのnameを取り出す
$aref = $self->dbh->selectcol_arrayref("SELECT name FROM $t{table}");
@{ $$a_ref{list} } = @$aref;
$$a_ref{name1} = $t{name1};
($a_ref) = check1($a_ref);
if ( $$a_ref{NG} == 1 ) {
$t{template} = $self->load_tmpl("$t{html2}") || die "error loading tmpl";
$t{template}->param(id => $t{id});
for $n ( 0 .. $#arr ) {
$t{name} = $arr[$n];
$t{value} = $arr1[$n];
$t{template}->param($t{name} => $t{value});
}
return $t{template}->output;
}
[Sun Sep 12 22:40:55 2010] [error] [client 127.0.0.1] DBD::mysql::db selectrow_array failed: Unknown column 'B' in 'where clause' at ./pro/mscshow241.pl line 59, line 11., referer:
修改思路(此类程序需要考虑$t{type1s1}不是整数的情况)
for $n ( 0 .. $#{ $t{type1s} } ) {
$t{type1s1} = $t{type1s}[$n];
59: $t{name1} = $self->dbh->selectrow_array("SELECT name FROM main_type1 WHERE id = $t{type1s1}");
push(@{ $t{type1} },$t{name1});
}
返回