Zend Certified Engineer

phpguru.org

Free PHP, Javascript and C# code

PEAR::DB database class(es) replacement


3rd June 2007, 1640 views

PEAR::DB is all well and good if you want to connect to multiple databases (I assume, I've never actually used it with anything other than mysql) but it is somewhat hefty on the bad side of 60k. Not a good thing if you're not using some sort of accelerator and have a high traffic site. Here's a class which replicates the PEAR::DB API (the bits that I use anyhoo) and weighs in at a much nicer ~11k. Sweet. Grab it from the download section.

Note

Something I don't believe I've published, or at least an't remember doing so, is the documentation: http://www.phpguru.org/pear_db_replacement/

Top 10 referrering pages

  1. http://www.google.co.uk/custom?domains=www.phpgur... (3 referrals)
  2. http://www.google.com/search?hl=nl&rlz=1G1GGLQ_NL... (2 referrals)
  3. http://www.richardheyes.com/downloads/datagrid/la... (2 referrals)
  4. http://www.google.lt/search?hl=lt&q=pear+db+quote... (1 referrals)
  5. http://www.google.com.vn/search?q=pear+db+class&b... (1 referrals)
  6. http://groups.google.com/group/php.general/browse... (1 referrals)
  7. http://www.google.lt/search?q=pear+DB%2C+speed&ie... (1 referrals)
  8. http://www.google.com/search?client=firefox-a&rls... (1 referrals)
  9. http://mail.google.com/mail/?ui=1&ik=&tf=1&source... (1 referrals)
  10. http://www.google.lu/search?q=PEAR+DB+abstraction... (1 referrals)
- +
Rate this article

Link to me

If you use any of the code on this site (and if you don't I guess) or it makes your life easier, I'd appreciate a link - http://www.phpguru.org. Thanks!

RSS Feed for Comments

Comments

Author: Brian Moon
Posted: 3rd June 2007 22:26
I must ask, if you only use it with MySQL why not use the mysql extension or mysqli if you want an OOP interface?
Quote
Author: David Coallier
Posted: 4th June 2007 03:16
The only problem here is that DB is deprecated in favor of MDB2, which is much smaller because of it's Driver model. Unlike DB, you install each driver (mssql, mysql, etc). You oonly install what you need.
Quote
Author: Richard Heyes
Posted: 4th June 2007 11:14
Brian Moon:
> I must ask, if you only use it with MySQL why
> not use the mysql extension or mysqli if you
> want an OOP interface?

Is it so hard to understand how someone may start with PEAR::DB for speed of development and subsequently their site gets to the point where they need all the speed they can get without wanting to change lots of code? The last place I worked at did this but did not want to change all the code (the resulting bugs would have been unmanageable) so this was the solution. Even with new projects it makes a certain amount of sense due to the shortcut methods and the time they can save you.
Quote
Author: Richard Heyes
Posted: 4th June 2007 11:16
David Coallier:
> The only problem here is that DB is deprecated
> in favor of MDB2, which is much smaller because
> of it's Driver model. Unlike DB, you install
> each driver (mssql, mysql, etc). You oonly
> install what you need.

Is it as small as 11k?
Quote
Author: Richard Heyes
Posted: 4th June 2007 11:30
David Coallier:
> The only problem here is that DB is deprecated
> in favor of MDB2

Might be worth putting a note in the docs that says this. I couldn't see one (mind that isn't saying much...) so it might be worth sticking a big fat [DEPRECATED] next to it on this page: http://pear.php.net/manual/en/package.database.php
Quote
Author: cool
Posted: 27th June 2007 15:20
New to pear:
are u guys saying that this replacemnt class for pear db id depricated?

i am developing sites that run on my server with SQLite db but these sites will end up being hosted on servers running mySql.

i would like to know if i can use this (pear db) replacement to accomplish this.

any additional info on db managemint and design would be appreciated.
Thank u very much.
Quote
Author: Richard Heyes
Posted: 27th June 2007 15:42
cool:
> New to pear:
> are u guys saying that this replacemnt class
> for pear db id depricated?

The PEAR::DB package is deprecated, this isn't.

> i am developing sites that run on my server
> with SQLite db but these sites will end up
> being hosted on servers running mySql.
>
> i would like to know if i can use this (pear
> db) replacement to accomplish this.

Well this class is MySQL only so I doubt it. You could lookat MDB2 in PEAR. Apparently that is the DB abstraction layer du jour. This is for (for example) sites started on PEAR::DB which are lacking in performance. Replacing the PEAR::DB API is one way to inrease performance.
Quote
Author: eseza
Posted: 23rd April 2008 12:53
your website is well done. very informative and the comments box doesnt take shit. wow
Quote

Post Comment

Your name:
Your email:
(Don't worry, I won't spam you. Also, if you do put your email address in here, you'll get notified of new comments. If you don't, you won't.)
Comments:
  Do not post support type questions please

 
CAPTCHA image If you can't read the CAPTCHA then press the submit button to get another. Your comment will re-appear (as if by magic...).
Captcha image