| Connecting PHP with MySQL |
When you are looking easy using the
MySQL client tools to operate data in the database, you can start using
PHP to show and change data from the database. PHP has standard meanings
for operational with the database.
First, we're going to talk about PHP's built-in database jobs. We'll
also demonstrate you how to use the PEAR database functions that give
the capability to use the same functions to contact any supported
database. That flexibility comes from a procedure called abstraction.
Abstraction includes details which you need to log into a database that
is placed into a normal format. This standard format permits you to
interact with MySQL as well as other databases using the same format. In
the same way, MySQL-specific functions are replaced with general ones
that know how to talk to many databases.
The Process
The basic steps of executing a query, when you are using the mysql
command-line tool or PHP, are the same:
• Attach to the database.
• Choose the database to use.
• Construct a SELECT statement.
• Execute the query.
• Display the results.
Resources
While you are connecting to a MySQL database, you will use two latest
resources. The first is the link identifier that holds all of the
information essential to attach to the database for an active
connection. The other resource is called the results resource which
includes all information required to get back results from an active
database query's result set. You'll be generating and conveying both
resources in this chapter.
|
|