Writing Scripts with PHP's PEAR DB Module
As a web programming language, one of PHP s strengths traditionally has been to make it easy to write
scripts that access databases so that you can create dynamic web pages that incorporate database content.
This is important when you want to provide visitors with information that is always up-to-date ...
This architectural approach has been used successfully with other languagesâ for example, to develop the
DBI (Perl, Ruby), DB-API (Python), and JDBC (Java) database access interfaces. Itâ s also been used with
PHP before; PHPLIB and MetaBase are two packages that provide an abstract database interface. How-
ev er, PEAR is included with PHP distributions and installed by default, so if you have a recent version of
PHP, you already have PEAR and can begin using it.
PEAR DB uses classes and objects to present an object-oriented interface, and this article assumes that you
are familiar with PHPâ s approach to object-oriented programming. If you are not, you may wish to review
the â â Classes and Objectsâ â chapter of the PHP Manual.
PEAR offers script writers control over the handling of PEAR errors. By default, PEAR calls return error
objects. This enables you to do whatever you want with the error information (such as printing an error
message), but on the other hand puts the burden on you to check the result of each call. Other approaches
are possible. For example, if you donâ t want to test the result of every call, you can set the error handling
mode to
PEAR_ERROR_DIE
to cause PEAR to print an error message and terminate the script automati-
cally if an error occurs.
...
Source: www.kitebird.com

Topic: