PHP Database Programming
Most applications that you will work with or encounter will involve the use of some
sort of data storage container. In some cases, you will need nothing more than files
for this purpose, but often, that container is some sort of database engine. PHP provides
access to a great number of different database systems, many of which are relational
in nature and can be interrogated using Structured Query Language (SQL).
In order to utilize these databases, it is important to have a firm grasp on SQL, as
well as the means to connect to and interact with databases from PHP. This chapter
reviews the basic concepts of SQL and database connectivity from PHP using PHP
Data Objects (PDO).
The only type of database that most developers will ever use is of the relational variety.
A relational database revolves, as its name implies, around the relationships
between the entities it contains.
The fundamental data container in a relational database is called a database or
schema. Generally speaking, a schema represents a namespace in which the characteristics
of a common set of data are defined. These may include the structure
of data, the data itself, a set of credentials and permissions that determine who has
access to the schema’s contents, and so on.
IMPORTANT: The term database is often used interchangeably when referring either to a specific
schema or to a server on which the database is stored.
The data is stored in structured containers called tables. A table is a bi-dimensional
collection of zero or more rows, each of which can contain one or more columns. In
other words, the columns define the structure of the data, while the rows define the