This chapter tackles quite a number of databases and shows the basic operations with them: connecting, sending SQL statements, and evaluating the return values. No matter what your database-driven web application must do, it always has to do these steps.
To have some test data, we created a database called hoshmand
in the relational database management system (RDBMS) and put a table called quotes
in there. This table consists of four fields:
-
id
An integer value that is increased by 1 for each new entry entered into the database. Depending on the database system, the data type is either calledIDENTITY
,auto_increment
, or something similar. -
quote
The quote, as aVARCHAR(255)
; this length works with all systems. -
author
The person who produced the quote, as aVARCHAR(50)
. -
year
The year the quote has been produced (sometimes, this is highly speculative), of typeINT
.
Every database system comes with either management tools or third-party products available. For instance, the PHP-based phpMyAdmin (http://www.phpmyadmin.net/
) shown in Figure 7.1 offers very good access to a MySQL installation.
Figure 7.1. Managing a MySQL installation using phpMyAdmin.
[View full size image]