Other Features

There are a number of PostgreSQL-related PHP functions that I have not covered in this chapter.

Newer versions of PHP have added support for asynchronous query processing (see pg_send_query(), pg_connection_busy(), and pg_get_result()). Asynchronous query processing probably won't be of much use when you are constructing dynamic web pages, but clever coders can use asynchronous queries to provide intermediate feedback for long-running operations (sorry, I'm not that clever).

PHP offers a set of functions that can give you information about a database connection. We used the pg_dbname() function in the first client (see Listing 15.4) to display the name of the database to which we were connected. You can also use the pg_port() and pg_options() function to retrieve the port number and options associated with a database connection. PHP provides a pg_host() function that is supposed to return the name of the host where the server resides. Be very careful calling pg_host(); if you have established a local connection (that is, using a Unix-domain socket), calling pg_host() may crash your web server because of a bug in the PHP/PostgreSQL interface.

Another function offered by PHP is pg_pconnect(). The pg_pconnect() function establishes a persistent connection to a PostgreSQL database. Persistent connections are cached by the web server and can be reused the next time a browser requests a document that requires access to the same database. See the PHP manual for information about the pros and cons of persistent connections.

Finally, PHP supports the PostgreSQL large-object interface. You can use the large-object interface to read (or write) large data items such as images or audio files.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset