Prev | Current Page 663 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

db");
// Register the aggregate function
sqlite_create_aggregate($sqldb, "computetotalgold", "total_salary",
"convert_to_gold",1);
// Query the database using the UDF
$query = "select computetotalgold(salary) FROM employees";
$result = sqlite_query($sqldb, $query);
list($salaryToGold) = sqlite_fetch_array($result);
// Display the results
echo "The employees can purchase: ".$salaryToGold." ounces.";
// End the database connection
sqlite_close($sqldb);
?>
If your employees??™ salaries total $16,000, you could expect the following output:
The employees can purchase 40 ounces.
Summary
The administrative overhead required of many database servers often outweighs the
advantages of the added power they offer to many projects. SQLite offers an ideal
remedy to this dilemma, providing a fast and capable back end at a cost of minimum
maintenance. Given SQLite??™s commitment to standards, ideal licensing arrangements,
and quality, consider saving yourself time, resources, and money by using SQLite for
your future projects.
591
?–  ?–  ?– 
C H A P T E R 2 3
Building Web Sites
for the World
The Web makes it incredibly easy for you to communicate your message to anybody
with an Internet connection and a Web browser, no matter if they??™re sitting in a caf?© in
Moscow??™s Red Square, in a farmhouse in Ohio, in a cubicle in a Shanghai high-rise, or
in an Israeli classroom.


Pages:
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675