Re: [PHP4BETA] DB.php

From: Date: Wed, 08 Dec 1999 15:54:18 +0000
Subject: Re: [PHP4BETA] DB.php
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-7678@lists.php.net to get a copy of this message
On Wed, 8 Dec 1999, Stig Bakken wrote: > On Tue, 7 Dec 1999, Andrei Zmievski wrote: > > | I fail to understand the purpose of DB class in PEAR. Is it supposed > | to be a factory class? Because it certainly does more than that. Why > | does it have fetchRow() and DB_mysql class has fetchRow(), yet DB class > | doesn't have query() method. > > There are two classes in DB.php: DB and DB_result. DB contains two > factory methods (factory and connect) as well as a bunch of functions > common to all of DB, such as rewriting error codes to messages. These > should always be used with the "static" syntax: DB::isError(). > > Then there's DB_common, which defines some default methods (sort-of > virtual), as well as a bunch of common utility methods I started writing > this morning. DB_common is only for inheritance from DB_[dbtype]. > > DB_[dbtype] implements only the database-specific stuff. The query() > method returns a DB_result object, which is defined DB.php (this is where > the fetchRow() method you mention comes from). > > Example: > > $dbobj = DB::connect("mysql://user:pass@localhost/mydb"); > // $dbobj is an instance of DB_mysql > $robj = $dbobj->query('SELECT * FROM mytable'); > // $robj is an instance of DB_result > > There's a lot of stuff in the DB code that needs the "return references" > rewrite though, just look for "XXX ADDREF". :-) This will not happen before PHP 4.1 or Zend 1.1. It would take too much time to stabalize. Andi

« previous php.version4 (#7678) next »