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 => "請選一個(gè)");
$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)
返回
绥江县|
孙吴县|
车险|
青海省|
全州县|
齐河县|
太仓市|
克山县|
泸州市|
新津县|
苗栗县|
余姚市|
和硕县|
宁远县|
酉阳|
永州市|
蓝田县|
海林市|
万宁市|
怀来县|
增城市|
怀化市|
高安市|
蒙山县|
沽源县|
张家川|
太和县|
涟源市|
临泉县|
邮箱|
凤冈县|
民丰县|
通道|
广平县|
东台市|
闽侯县|
英吉沙县|
石门县|
西充县|
墨竹工卡县|
拉萨市|
|