473,416 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

how do people feel about the PEAR db class?


I wrote a simple CMS for personal use. I'm thinking of using it for
other clients now. It's use of the database is slow and inefficient.
I'm thinking of switching to the PEAR class listed here:

http://pear.php.net/package/DB

What do people think of it?

Mar 10 '06 #1
8 1546
The DB class is just a wrapper and light abstraction for the various
databases php supports. It won't improve the efficency of your code,
for the most part. You should look at your queries and code to see if
you can cut some of the fat from it.

I highly suggest using it, however.

Mar 11 '06 #2
Indexes play a big part in database performance as well. Make sure you
are searching on indexed fields.

Scott

lawrence k wrote:
I wrote a simple CMS for personal use. I'm thinking of using it for
other clients now. It's use of the database is slow and inefficient.
I'm thinking of switching to the PEAR class listed here:

http://pear.php.net/package/DB

What do people think of it?

Mar 11 '06 #3
NC
lawrence k wrote:

I wrote a simple CMS for personal use. I'm thinking of using it for
other clients now. It's use of the database is slow and inefficient.
I'm thinking of switching to the PEAR class listed here:

http://pear.php.net/package/DB

What do people think of it?


Personally, I think it's a resource hog and a performance drag. As a
matter of fact, all DB abstraction layers are. For more information,
see here:

http://phplens.com/lens/adodb/

So you should avoid using abstraction layers whenever possible.

Cheers,
NC

Mar 11 '06 #4
"NC" <nc@iname.com> posted:
For more information, see here:
http://phplens.com/lens/adodb/
So you should avoid using abstraction layers whenever possible.


Hello, NC,

The link you provided might be confusing to some. It specifically
describes their own ADODB thing, and fails to differentiate that
from Microsoft ADODB (which may or may not be realized by
the reader which then makes the link kind of confusing).

Abstraction layers usually provide something easier to use than
the root methods involved in connecting to databases and querying.
Sometimes they only provide friendlier names and run the same
code (perhaps with some error handling), so the end result may
that the only difference involved is the time it takes to set up the
call, and the time it takes to debunk the call, which in many cases
is something that network connections might be the only purely
visible wait. What I mean, is that IF you extract ALOT of data,
the network connection might be so slow and the processor then
waits upon the network to conclude its delivery. Another thing
involves the hard disk access speed, whereby the processor waits
on the hard disk to deliver the items to memory, which then waits
for memory to deliver the items to the nic, which then waits for
the nic to deliver the items to the host. All in all, the end user never
sees the processor wait the extra micro-second and even if they do
start timing it, the network connections are going to represent the
biggest bottle-neck.

Whew. Now, one needs to ask what the purpose of an abstraction
layer is. What exactly is the purpose? Only one answer exists and it
has nothing to do with speed. It's to provide a COMMON set of
routines to access any type of data. It ends up as an ease of use
thing:

(1) Connect to the db,
(2) Read such and such record from the db,
(3) Perform ops on the record retrieved (inspect it, is it the one you
really wanted?/modify it/delete it/present it to the end-user).
(4) Finish up with the recordset, close it out.
(5) Do some more work with the same connection or close the
connection.

Your final statement, "So you should avoid using abstraction layers
whenever possible," sat awkward and lacked an explanation, so I
took it upon myself to provide the information for the OP and anyone
else reading the thread (as well as myself).

Jim Carlock
Pos replies to the group.
Mar 12 '06 #5
Just to justify NC a bit, PEAR::DB is a bit bloated and slow, and its
interface is cumbersome. It isn't the best database abstraction layer
out there. It is still, I believe, based upon and using PHP4
objects/concepts.

There is also the PDO stuff, I haven't looked that though, but I think
its a compiled (native C) thing, so it probably hauls ass.

That doesn't detract from Jim's statements about abstraction layers.
What abstraction layers lose in performance (which is miniscule, for
the most part), they gain in ease of use, portability, and
maintainability.

Mar 12 '06 #6
NC
Richard Levasseur wrote:

What abstraction layers lose in performance (which is miniscule,
for the most part), they gain in ease of use, portability, and
maintainability.


I respectfully disagree.

Ease of use is a matter of opinion; what is easy to me is not
necessarily easy to you and vice versa. Our discussion is the case in
point; you think it is possible to simplify database access by
introducing an abstraction layer, while I think that calls to native
API functions are simple enough... :)

Portability (if, in the context of this discussion, we define it as the
application's ability to use multiple database engines) and
maintainability are conflicting goals -- maintainability decreases with
the size of code base, while portability requires expansion of the code
base, so portable applications are by definition more difficult to
maintain. Code that does not rely on abstraction layers is by
definition more maintenable, simply because developers don't have to
maintain the abstraction layers themselves.

Loss of performance, however, is objectively measurable and LARGE (at
least, that's what phpLens benchmarks show, and, to the best of my
knowledge, no one has produced a benchmark test with markedly different
results). There is no evidence that points to "miniscule" performance
losses you spoke of; the evidence suggests that the losses are
substantial. If you are aware of any benchmarks that support your
claim, please share your knowledge, and I will happily reconsider my
position.

Cheers,
NC

Mar 13 '06 #7
NC wrote:
Richard Levasseur wrote:

What abstraction layers lose in performance (which is miniscule,
for the most part), they gain in ease of use, portability, and
maintainability.
I respectfully disagree.

Ease of use is a matter of opinion; what is easy to me is not
necessarily easy to you and vice versa. Our discussion is the case in
point; you think it is possible to simplify database access by
introducing an abstraction layer, while I think that calls to native
API functions are simple enough... :)


Calls to native API functions are great, but i got tired of writing the
same code over and over, copy and pasting the same code over and over,
and generally adding more code that, when a change was required, forced
me to go back through it all and fix each independent instance.
Portability (if, in the context of this discussion, we define it as the
application's ability to use multiple database engines) and
maintainability are conflicting goals -- maintainability decreases with
the size of code base, while portability requires expansion of the code
base, so portable applications are by definition more difficult to
maintain. Code that does not rely on abstraction layers is by
definition more maintenable, simply because developers don't have to
maintain the abstraction layers themselves.
Just because there is a lot of code doesn't mean it isn't maintainable
(in the sense of, "I'm going to go smoke a pack of cigarettes before I
touch this, then call a therapist afterwards").

How an abstraction layer makes it more maintainable is it becomes
easier to make changes. You only have to do a couple of things
(function calls, object creations, whatever) to get the result you
need. As compared to making the same however-many api calls again. If
those api calls were always going to be that way, forever and ever,
then sure, the one with abstraction would be harder to maintain. But,
that is rarely (if ever?) the case (oh how I pray for such a day when
it's write once and never look at it again).

Now, which is more maintainable, the code where you simply tell the
abstraction you're working with something from somewhere else (putting
pgsql://: instead of mysql://), or go ing through and changing all the
mysql_ to pgsql_, add/remove the prepares/executes, change the
number_rows to numrows, etc etc.

Thats how an abstraction makes it more maintainable. Additionally, the
code the abstraction uses to interface to the underlying thing, be it a
database, file, whatever, is going to be seperate and (i hope to god)
self contained, again, making it easier to manage the seperate parts of
the abstraction.

Personally, I opt for the abstraction. It makes my life a lot easier
and I can get more done while leaving myself the option of adding more
faster.
Loss of performance, however, is objectively measurable and LARGE (at
least, that's what phpLens benchmarks show, and, to the best of my
knowledge, no one has produced a benchmark test with markedly different
results). There is no evidence that points to "miniscule" performance
losses you spoke of; the evidence suggests that the losses are
substantial. If you are aware of any benchmarks that support your
claim, please share your knowledge, and I will happily reconsider my
position.
Just to be clear, I'm not defending PEAR::DB's performance. It does
suck.
Another clarification I should make is that most abstractions don't
produce huge performance differences, I wasn't specifically refering to
only pear::db, because pear::db is sloooow compared to even my own
abstractions i've made. To be honest, after trolling through the
pear::db code, i've been weary of using anything from pear - but its
theres, it works, and it does what i need, so i use it.
Anyways, I'm not going to argue performance details, though, not for
anything PHP. I think it, for the most part, is silly because PHP is a
scripting language. Unless you're making some fundamental errors with
how you're processing the data, you're never going to get
whiz-ping-boing performance out of it, if you want that, you might want
to pick a lower level language and use PHP as the glue between it and
the web. Thats just my honest opinion though.
Cheers,
NC

Perhaps I'm a bit bias though. My specs change every day I come into
work, despite my meticulous planning and tearful, heart-wrenching pleas
to keep them the same until I, at the least, get the chance to say I
actually got something done.

-Richard

Mar 13 '06 #8
On Sun, 12 Mar 2006 14:16:28 GMT, "Jim Carlock" <an*******@127.0.0.1>
wrote:
"NC" <nc@iname.com> posted:
For more information, see here:
http://phplens.com/lens/adodb/
So you should avoid using abstraction layers whenever possible.


Hello, NC,

The link you provided might be confusing to some. It specifically
describes their own ADODB thing, and fails to differentiate that
from Microsoft ADODB (which may or may not be realized by
the reader which then makes the link kind of confusing).

Abstraction layers usually provide something easier to use than
the root methods involved in connecting to databases and querying.
Sometimes they only provide friendlier names and run the same
code (perhaps with some error handling), so the end result may
that the only difference involved is the time it takes to set up the
call, and the time it takes to debunk the call, which in many cases
is something that network connections might be the only purely
visible wait.


I *think* (and I could be wrong) that Adodb and PhpLib also provide
some query-filtering that can help with security for people who could
otherwise be leaving themselves open to attacks?

Also Adodb now has what looks like a nice cacheing function (but I
haven't tried it)
--
Locate your Mobile phone: <http://www.bizorg.co.uk/news.html>
Great gifts: <http://www.ThisBritain.com/ASOS_popup.html>
Mar 13 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Arne Kösling | last post by:
Hi ! I am new to Web Services. Therefore I ve set up a PHP Installation on Windows (PHP 4.3.2 and Apache 1.3.29). I have tested PHP alone and then installed PEAR. Now I am stuck there (Before...
0
by: Bob Brown | last post by:
Hi All, For a project I'm working on I wanted to be able to add extra functionality to Pear's DB class. I can add the functionality as stand-alone functions, but as they were to do with the...
3
by: Sandro Dentella | last post by:
I need to use a class to handle mbox files that uses PEAR. Since I'm using Debian (both woody and, I simply apt-get(ed) php4-pear but I can't use it becouse I get the error: Warning: dl():...
13
by: Wolfgang May | last post by:
Hi, I have a problem with the HTTP implementation of the PEAR package: I try to PUT an XML instance to an XML database (eXist), but it always puts a binary: <?php require_once...
1
by: DJ Majestik | last post by:
OK, I am new to the whole PEAR/Smarty templating thing. I am trying to setup my directory structure correctly. If someone could weigh in and see if I have this setup "right", I would appreciate it....
3
by: David | last post by:
I installed the Pear program and set the include path in php.ini to point to the pear dir. I have a program which <? require_once("DB.php"); ?> This produces the error "Class 'PEAR_Error'...
1
by: webguynow | last post by:
I've installed PEAR in my local area, on my shared host, under htdocs but I'm anticipating a number of issues. I'm forcing use of PHP5 with an .htaccess file, but by default the host runs ...
0
by: Samuel Zallocco | last post by:
Hi all, I've a problem with PHP5 + PEAR::SOAP. I Have the following 2 script that implements a simple web service: The Server Code running on WinXP + PHP5 + Apache 2.x:...
1
by: CSTechie | last post by:
I've been battling to install PEAR on Windows XP now for too long. I am not sure what I need to do. When I run go-pear.php from the command line, I get the error message as shown at the end. I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.