Article

Home » Server-side Coding » Server Side Essentials » Beginning Databases with PostgreSQL - Chapter 15: Accessing PostgreSQL from PHP

Beginning Databases with PostgreSQL - Chapter 15: Accessing PostgreSQL from PHP

By Wrox Press

November 21st, 2001

Reader Rating: 9

Page: 1 2 3 4 5 6 7 8 9 10 11 12 Next

This article is an excerpt of the book, Beginning Databases with PostgreSQL (Wrox Press, 2001), and is reprinted here by permission.

Recently, there has been a strong trend towards providing web-based interfaces to online databases. There are a number of reasons supporting this movement, including:

  • Web browsers are common and familiar interfaces for browsing data
  • Web-based applications can easily be integrated into an existing web site
  • Web (HTML) interfaces are easily created and modified

In this chapter, we will explore various methods for accessing PostgreSQL from PHP. PHP is a server-side, cross-platform scripting language for writing web-based applications. It allows you to embed program logic in HTML pages, which enables you to serve dynamic web pages. PHP allows us to create web-based user interfaces that interact with PostgreSQL.

In this chapter, we will assume at least a basic understanding of the PHP language. If you are completely unfamiliar with PHP, you might want to explore some of the following resources first:

  • The home site of PHP http://www.php.net
  • Beginning PHP 4, Wankyu Choi, Allan Kent, Ganesh Prasad, and Chris Ullman, with Jon Blank and Sean Cazzell, Wrox Press (ISBN 1-861003-73-0)

There are many different schools of thought concerning PHP development methodologies. It is not within the scope of this book to discuss them. Instead, we will focus on designing PHP scripts that make effective use of PHP's PostgreSQL interface.

Note that we will be focusing on PHP version 4. While most of the following code examples and descriptions will apply to earlier versions of PHP, there may be a few differences in functionality. In addition, it is assumed that all code snippets fall within the context of valid PHP scope (generally meaning with the <?php ?> tags), unless otherwise specified.

If you liked this article, share the love:
Print-Friendly Version Suggest an Article