Re: [SMARTY] Smarty and DB Abstraction

From: Date: Mon, 10 Jun 2002 07:25:40 +0000
Subject: Re: [SMARTY] Smarty and DB Abstraction
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-4717@lists.php.net to get a copy of this message
At 08:54 10/06/02 +0200, pemphp wrote:
Hi, I work with Smarty for few months. I work already with Phplib DB class. I'm searching for another DB abstraction class. Have youever heard about a benchmark between different DB Solution (PEAR DB, ADODB, Phplib, ...)
They fall into two classes for speed: Native calls and PHPLib; Proper abstraction: PEAR-DB, ADODB, MDB; PHPLib is so fast because it is a poorly written class, and hence has a speed advantage. Quoting Kristian Koehntopp <kris@koehntopp.de>, the author of PHPLib: "From an OO design POV phplib has extremely badly designed database classes. That's why they are that fast. :-) No, really, PHPLIB was written on and for PHP3. That is an environment where classes really are nothing more than namespaces, and where state and code cannot be kept efficiently in memory, like for example it would be possible in an application server and with truly compiled code. OO design techniques strongly favor such an appserver execution environment, and PHP does not offer such an environment at all, in fact, it almost offers the antithesis to such an environment. PHPLIB was written with the particular execution model used in PHP in mind and tested on sun4m hardware. That's why it performs adequately, even today. It is not a bit fashionable, though." - ADODB has some nice features, but I hate its method names (they don't make sense to me) and has a strange way of doing some things IMHO - that should be separated into separate classed. - PEAR-DB is slightly slower than ADODB, but has more comprehensive error checking, and has a lovely API... which is also going to become the PHP standard - MDB is faster than PEAR-DB and is slowly being phased in to replace it. It combines the abstraction capabilities of Metabase with PEAR-DB's API.
Is PEAR DB is really competitive ?
Depends what you compare against :-)
Is there a good choice with Smarty ?
I'd go for PEAR-DB as so many people are already using it, so if people write extensions involving database interactions then that's a good chance that this is the library that will be used. A lot of people fell for the hype about ADODB when John Lim released his benchmarks - what he didn't point out was that he didn't benchmark the time taken to compile the libraries in the first place, and the fact that his queries were very simple. PEAR responded by writing a new release of PEAR-DB that was as fast as ADODB, but it was never released - IIRC because it messed up the class separation and error handling. So we're still stuck with a slow DB abstraction layer :-) Here's some recent benchmarks off the PHPLib mailing list: "I altered tests [that John Lim ran] and stated timing before any includes. And I was surprised. For example, doing 1 query (after altering tests) took: mysql: 0.03 sec, phplib: 0.06 sec, adodb: 0.14 sec, pear: 0.17 sec." And the ones produced for mdb: http://www.dybnet.de/MDB/benchmarks.pdf HTH! Peter -- Maple Design - quality web design and programming http://www.mapledesign.co.uk

« previous php.smarty.general (#4717) next »