15
@book_infos
["Ooba
[
"Ooba2006"
] = BookInfo.
new
(
09
# テーブルに登録されたデータを削除する
10
# deletet文の実行
11
dbh.execute(
"delete from products"
)
12
puts
"all records are deleted."
# sthにexecuteメソッドが返すステートメントハンドルを保持
sth = dbh.execute(
13
14
# ステートメントハンドルを解放する
16
# (本書上ではこの処理が抜けてエラーになっている)
17
sth.finish
# executeメソッドでレコードを削除するSQLを実行後、
# finishメソッドでステートメントハンドルを開放する
).finish
41
#
42
#class TestCGI < WEBrick::CGI
43
# def do_GET(req, res)
44
# res["content-type"] = "text/plain"
45
# ret = "hoge\n"
46
# res.body = ret
47
# end
48
#end
49
50
#TestCGI.new.start()
5
require
'rubygems'
6
'dbi'
7
# sqlite-rubyが返すencodingへの対策
8
'enc_patch'
<
td
><
input
type
=
"radio"
name
"oparation"
value=<%="#{val}.delete"%> /></
>
value=<%="#{val}.edit"%> /></
"operation"
if
/(.*)\.(delete|edit)$/ =~ req.query[
'oparation'
]
'operation'
54
<td><input type=
name=
value=<%=
"#{row[name]}.delete"
%> /></td>
55
"#{row[name]}.edit"