Database Reference
In-Depth Information
print
header
();
print
start_html
(
-
title
=>
"Tables in cookbook Database"
);
print
p
(
"Tables in cookbook database:"
);
# Connect to database, display table list, disconnect
my
$dbh
=
Cookbook::
connect
();
my
$stmt
=
"SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'cookbook' ORDER BY TABLE_NAME"
;
my
$sth
=
$dbh
->
prepare
(
$stmt
);
$sth
->
execute
();
while
(
my
@row
=
$sth
->
fetchrow_array
())
{
print
$row
[
0
],
br
();
}
$dbh
->
disconnect
();
# Print page trailer
print
end_html
();
Install the
show_tables_fc.pl
script in your
cgi-bin
directory and request it from your
browser to verify that it produces the same output as
show_tables_oo.pl
.
This topic uses the CGI.pm function call interface for Perl-based web scripts from this
point on. You can get more information about CGI.pm at the command line by using
the following commands to read the installed documentation:
%
perldoc CGI
%
perldoc CGI::Carp
Documentation is also available online from
CPAN
.
Ruby
The Ruby
cgi
module provides an interface to HTML-generating methods. To use it,
create a
CGI
object and invoke its methods to produce HTML page elements. Method
names correspond to the HTML elements they produce. Their invocation syntax follows
these principles:
• If an element should have attributes, pass them as arguments to the method.
• If the element has body content, specify the content in a code block associated with
the method call.
For example, the following method call produces a
<P>
element that includes an
align
attribute and content of “This is a sentence”:
cgi
.
p
(
"align"
=>
"left"
) {
"This is a sentence."
}