Logo name

Practical PHP Programming:Databases

From IpbWiki

  • Currently5.00/5
Jump to: navigation, search

Many people believe database access in PHP is its most important feature, and the PHP team have indeed made it as easy as they can to interact with databases using the language. I think it is fair to say that a PHP developer who has yet to come into contact with databases really has only touched the tip of the PHP iceberg!

In this chapter we will start off with a brief description of what makes up a database, what is provided by a database manager (the program that you use to interact with the database), and a history of the most popular database manager. In the section entitled SQL you will learn how to create and store information in a database using the Structured Query Language, and also how to get it out again just as you like it. We'll also be extensively covering how to interact with your database manager using PHP, how to format your data, and much more – this is a big chapter!

In order to be able to get into serious depth on this topic, we're going to be looking specifically at the MySQL database manager – more precisely, version 4 of MySQL. This is no great loss, because MySQL 4 is the most popular open-source database in existence, so chances are you will be using it. Although we will be sticking fairly closely to MySQL, much of what we cover here will apply to other databases easily. Having said all that, there are a number of things that are not supported in the stable release of MySQL, so this chapter also looks at how to use Microsoft SQL Server 2000 where MySQL falls down.

It is important to note that you do not need to know everything covered here – normalisation, for example, is helpful to know if you really want to perfect your database skills, but you can wing it without such knowledge. Similarly, you can skip over the detailed information on the PEAR database system if you have no intention to use it.

Topics covered in this chapter are:

  • What makes a database
  • What databases are available
  • SQL commands using MySQL
  • Connecting to MySQL through PHP
  • Using PEAR::DB for database abstraction
  • SQLite for systems without a database system
  • Normalisation and table joins
  • Table design considerations
  • Persistent connections and transactions


Chapter contents


Next: Practical_PHP_Programming:Introduction to databases

This page was last modified on 17 October 2006, at 12:41.  This page has been accessed 2,753 times.  Content is available under GNU Free Documentation License 1.2Disclaimers