|
Listing 14-1 (continued)
$sql = “SELECT * from Customer”;
$result = $db->query($sql);
if(DB::isError($result))
{
die($result->getMessage());
}
echo “<html>
<head><title>Customer List</title></head>
<body>
<table width=\”100%\” border=\”0\”>\n”;
while($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
{
if(DB::isError($row))
{
die($row->getMessage());
}
echo “<tr>”;
echo “<td>{$row[‘lastname’]}, {$row[‘firstname’]}</td>
<td>{$row[‘phone’]}</td>”;
echo “</tr>\n”;
}
echo “</table></body></html>”;
?>
The output is a list of customer names in the following format:
Lastname, Firstnamephonenumber
Using PEAR libraries is easy in terms of getting access to them. The PEAR
installer installs the package, and you just include it with a
require_once
statement. However, each package has its own functions and classes and
methods for accomplishing tasks. In a way, each new package is like learning
a new language. The things you know about PHP may not help you at all. Some
PEAR packages are documented well in the PEAR manual, online documenta-
tion, and books. Other PEAR packages are not documented as thoroughly.
318
Part IV:Common PHPApplications
|