Re: [phplib] [Fwd: [PHP-PEAR] Merging PHPLIB into PEAR] From: Kristian Koehntopp (kris <email protected>)
Date: 01/18/01

In netuse.lists.phplib you write:
>Is PEAR::DB really good enough? Read through the messages at
>the bottom of
><http://www.phpbuilder.com/columns/allan20010115.php3> and
>you'll see why I'm asking.

PEAR::DB and PHPLIB::DB_Sql

Different concepts. PEAR::DB tries to be a useful class all on
its own. No class in PHPLIB tries that.

The main idea of PHPLIB is that you have many pages, a web
application, all of which use the same classes. PHPLIB
encourages you to subclass the PHPLIB classes and overwrite the
class variables with the defaults you need. On the pages where
you need functionality, all you need to do is

        $db = new My_DB_Sql_Subclass();

and you are set. All needed connection information is magically
available, as it is the same on all your pages of a single
application anyway. We need to teach this way of thinking to the
PEAR people, it is an open issue, and a concept central to
PHPLIB.

The thing that varies from each use to use in a DB class is the
query. That's why you can specify the query as a parameter to
the constructor in newer instances of PHPLIB,

        $db = new My_DB_Sql_Subclass("select ...");
        while($db->next_record()) {
                do_something_with_record();
        }

It is of little use to specifiy connection parameters as
constructor parameters, as these are essentially all the same in
your web application, and should be specified only once, in your
subclass definition.

There are other places (Table comes to mind) where the same
paradigm applies.

Kristian

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>