Приглашаем посетить
Чернышевский (chernyshevskiy.lit-info.ru)

Chapter 17: PHP and MySQL

Table of Contents
Previous Next

Chapter 17: PHP and MySQL

Overview

One huge benefit of using a scripting language like PHP is the ability to generate dynamic content. However, it is important to consider the source of that content. We have already seen how input can be received from the user – from session storage, and from flat text files. Now, we will learn how to use the power of a relational database to serve content for a PHP-driven application.

Truly sophisticated data-driven web applications use database management systems (DBMS) for a number of reasons. First, using the Structured Query Language (SQL), the web programmer can offload most of the data storage and management tasks to the database system. Second, databases are better at managing large amounts of data than we are, so we might as well let them do what they do best. Third, databases are persistent while variables and their data in PHP scripts generally only exist for the life of a given page request. Because of this persistence, databases can make more intelligent decisions on things such as disk performance and memory caching.

Using a database to store information also allows the PHP developer to write less code (being that data- handling tasks are being outsourced to the database management system) and abstract away the entire data management system.

This chapter will focus specifically on the MySQL interface. Some of the other PHP database interfaces, such as PostgreSQL, ODBC, and Oracle are covered in later chapters. In this chapter, we will cover the following topics:

If you are already familiar with relational database concepts and SQL, you may want to jump ahead to the PHP-specific section of this chapter, PHP and Relational Databases. If you are familiar with relational databases and SQL in general but not with MySQL specifically, you may want to browse this chapter, as the syntax tends to vary slightly between DBMSs. If you are not familiar with relational databases, keep in mind that this chapter provides only a cursory introduction to the topic. Many in-depth volumes have been written concerning relational database theory and best practices, such as:


Table of Contents
Previous Next