mscs_engine.pl
if ( $t{word} ) {
# 读name1
$t{sth} = $self->dbh->prepare("SELECT id,name FROM main_name1");
$t{sth}->execute;
while ( @rec = $t{sth}->fetchrow_array ) {
$t{name1}{$rec[0]} = $rec[1];
}
$t{sth}->finish;
# 读maker1
$t{sth} = $self->dbh->prepare("SELECT id,name FROM main_maker1 where name is not NULL");
$t{sth}->execute;
while ( @rec = $t{sth}->fetchrow_array ) {
$t{maker1}{$rec[0]} = $rec[1];
}
$t{sth}->finish;
# 检索main_type1
$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{gname} = $t{name1}{$rec[2]};
$t{maker} = $t{maker1}{$rec[3]};
$t{line} = $rec[1] . ' ' . $t{gname} . ' ' . $t{maker};
$t{line} = lc($t{line});
if ( $t{line} =~ /$t{word}/ ) {
my $row_ref = (); # 非常重要!
$$row_ref{id} = $rec[0];
$$row_ref{Line} = $t{gname} . '' . $rec[1] . ' | ' . $t{maker};
$$row_ref{enq1_id} = $t{enq1_id};
$$row_ref{item} = $t{item};
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 => "请选一个");
$t{template}->param(THIS_LOOP => \@loop);
}
mysql> show columns from main_type1;
+----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(100) | YES | | NULL | |
| series | text | YES | | NULL | |
| gname_id | text | YES | | NULL | |
| maker_id | text | YES | | NULL | |
| GR | text | YES | | NULL | |
| DWG | text | YES | | NULL | |
| memo | text | YES | | NULL | |
+----------+--------------+------+-----+---------+----------------+
8 rows in set (0.13 sec)
mysql> show columns from main_name1;
+-------+-----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-----------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | char(100) | YES | | NULL | |
| memo | text | YES | | NULL | |
| cname | char(100) | YES | | NULL | |
| cmemo | text | YES | | NULL | |
| jname | char(100) | YES | | NULL | |
| jmemo | text | YES | | NULL | |
+-------+-----------+------+-----+---------+----------------+
mysql> show columns from main_maker1;
+-------+-----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-----------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | char(100) | YES | | NULL | |
| memo | text | YES | | NULL | |
| cname | char(100) | YES | | NULL | |
| cmemo | text | YES | | NULL | |
| jname | char(100) | YES | | NULL | |
| jmemo | text | YES | | NULL | |
+-------+-----------+------+-----+---------+----------------+
7 rows in set (0.22 sec)
返回
|