PEAR DB - Useful?

This is a discussion on PEAR DB - Useful? within the PHP Language forums, part of the PHP Programming Forums category; What are people's thoughts on this class? IMHO, it seems like it's overkill for what most developers need. ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-08-2005
ryan@carsonworkshops.com
 
Posts: n/a
Default PEAR DB - Useful?

What are people's thoughts on this class? IMHO, it seems like it's
overkill for what most developers need.

I've been using it for awhile now, and I tend to use only about 3% of
it's functionality.

Thoughts? Opinions?
-----------------
One Day PHP/MySQL Workshop
www.carsonworkshops.com

Reply With Quote
  #2 (permalink)  
Old 01-08-2005
leegold2
 
Posts: n/a
Default Re: PEAR DB - Useful?

ryan@carsonworkshops.com wrote:
> What are people's thoughts on this class? IMHO, it seems like it's
> overkill for what most developers need.
>


I started using it then I canned it and returned to the standard PHP. It
became an issue spending time learning a big class or geting my work
done. If the documentation was more user oriented-with more everyday
working examples I could use it maybe. My code was becoming "too
abstracted" too obtuse. Less maintainable w/the DB class.

But maybe it's more my own preference or even limitation that I didn't
use it. I need my code *obvious* above all elese.




> I've been using it for awhile now, and I tend to use only about 3% of
> it's functionality.
>
> Thoughts? Opinions?
> -----------------
> One Day PHP/MySQL Workshop
> www.carsonworkshops.com
>

Reply With Quote
  #3 (permalink)  
Old 01-08-2005
Jan Pieter Kunst
 
Posts: n/a
Default Re: PEAR DB - Useful?

ryan@carsonworkshops.com wrote:
> What are people's thoughts on this class? IMHO, it seems like it's
> overkill for what most developers need.
>
> I've been using it for awhile now, and I tend to use only about 3% of
> it's functionality.
>
> Thoughts? Opinions?


I use it and like it, even if the part I like is only ..% of its
functionality. What I like:

- central error reporting, no "or die()" all over the place

- nice shortcuts for getting single values or arrays in one pass,
without looping (getOne(), getCol(), getAssoc())

- automatic escaping of values with prepared statements:

$query = 'insert into table (field1, field2) values(?,?)';
$pear_db_object->query($query, array($raw_data1, $raw_data2));


JP


--
Sorry, <devnull@cauce.org> is a spam trap.
Real e-mail address unavailable. 5000+ spams per month.
Reply With Quote
  #4 (permalink)  
Old 01-08-2005
kicken
 
Posts: n/a
Default Re: PEAR DB - Useful?

ryan@carsonworkshops.com wrote:
> What are people's thoughts on this class? IMHO, it seems like it's
> overkill for what most developers need.
>
> I've been using it for awhile now, and I tend to use only about 3% of
> it's functionality.
>
> Thoughts? Opinions?
> -----------------
> One Day PHP/MySQL Workshop
> www.carsonworkshops.com
>


I use it and like it quite well. I also only use probably only a small
amount, but I find it makes things much more manageable and a bit easier
to read/understand. I like the fact that provided I produce complient
SQL, all I have to do is change the connect string and I can use it to
work with more or less any database out there. Personally I only use
mysql, but for projects I make which I distribute, like my IRC bot, I
can say that it can, theoretically, be used with databases other than mysql.

I also like the if (DB::isError($result)) part, as it makes error
checking eaiser. Now I don't have to worry about 'for this sql
statement, what constitues an error' type things. Coupling that with
PHP5's exceptions and stuff, I do things like this:

if (DB::isError($res)){
throw new DatabaseException('Unable to query for ...', $res);
}

then my DatabaseException class can examine the $res varible and provide
debugging information in a log file. Again couple these exceptions with
templates(smarty) and a logError function, I can do things like this:

if (DB::isError($res)){
logWWWError($tpl, new DatabaseException('Unable to query for ...',
$res), __FILE__, __LINE__);
exit;
}

and not only do I get quick error checking, but I get a nice log file
with sql error details and also a generated error page which is shown to
the user with the message from the exception. Makes my applications
look nicer, and run a bit smoother I think.
Reply With Quote
  #5 (permalink)  
Old 01-08-2005
Chung Leong
 
Posts: n/a
Default Re: PEAR DB - Useful?

"ryan@carsonworkshops.com" <google@carsonsystems.com> wrote in message
news:1105175181.455425.137920@c13g2000cwb.googlegr oups.com...
> What are people's thoughts on this class? IMHO, it seems like it's
> overkill for what most developers need.


Overkill isn't the right word. I would say it just doesn't work that well in
most situations. Unless your application performs very basic queries, the
class buys you little in terms of cross platform compatibility, as most
advanced queries requires vendor specific SQL syntax. This "then it'll work
with any database!" argument is rather bogus anyway, since few people have
the resources to actually QA the different setups.



Reply With Quote
  #6 (permalink)  
Old 01-09-2005
R. Rajesh Jeba Anbiah
 
Posts: n/a
Default Re: PEAR DB - Useful?

ryan@carsonworkshops.com wrote:
> What are people's thoughts on this class? IMHO, it seems like it's
> overkill for what most developers need.


I hate PEAR. For database abstraction, I use phpBB like setup.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Reply With Quote
  #7 (permalink)  
Old 01-11-2005
ryan@carsonworkshops.com
 
Posts: n/a
Default Re: PEAR DB - Useful?

The reason why I asked is because I think the PEAR DB class is a
classic case of OO over-abstraction. We've noticed a significant gain
in run-time efficiency by going procedural, instead of using a class to
connect to the DB. It almost seems backwards, but if it makes the
application 10% faster, then who's to argue?!

----------------------------------------------
One Day PHP/MySQL Workshop
www.carsonworkshops.com

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 10:08 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0