Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-02-2006, 02:09 PM
WebProWorld Pro
 

Join Date: Feb 2004
Location: England Baby!
Posts: 222
icb01co2 RepRank 0
Default Why should i use Pear::DB?

Hi All,
I have been developing sites with php for a while now, and I am now looking at other more advanced tools that I should be using. I have scanned through the Pear projects and as someone who is used to simply using what the basis php libary has to offer this stuff interests/scares me.

My question specifically is about the Pear::DB libary. Quite simply, why should I use it? What advantages does it have over me using the standard db connection functions the php lib has?


Finally, what other Pear projects should i be interested in?
Chris.
Reply With Quote
  #2 (permalink)  
Old 04-02-2006, 07:57 PM
Easywebdev's Avatar
WebProWorld Veteran
 

Join Date: Apr 2004
Posts: 328
Easywebdev RepRank 1
Default Re: Why should i use Pear::DB?

Quote:
Originally Posted by icb01co2
My question specifically is about the Pear::DB libary. Quite simply, why should I use it? What advantages does it have over me using the standard db connection functions the php lib has?
The first question you should ask yourself is do you need to use it?

The idea behind Pear::DB or any database abstraction layer is to place all database specific code in a single class wrapped by your own functions. If you use MySQl as you db of choice then you can use a MySQL abstraction layer/class, need to use Postgre at some point in the future then you just swap the layer/class for one that deals with Postgre, no code editing needed as all your code makes calls to your db functions rather than database specific functions.

I don't use any of the pear libraries myself, most php programmers will find them bloated and overkill for most situations and usually end up developing their own php framework that handles db abstraction, templating, mailing, sessions, input sanitization and more depending on the level of application they are developing.

Pear wil get the job done but if I were in your shoes I would be looking to develop a small framework that you understand totally rather than learning to interact with pear libraries.

Checkout phpclasses.org you will find most of what you will need in there.
Reply With Quote
  #3 (permalink)  
Old 04-02-2006, 08:05 PM
WebProWorld Pro
 

Join Date: Feb 2004
Location: England Baby!
Posts: 222
icb01co2 RepRank 0
Default

Thanks, Easywebdev.

To be honest, ive looked through the Pear libary, and although I agree with what your saying, implementing Pear::DB seems as simple as using the standard php DB functions. So I may as well go with the Pear option.

Additionally, I have found the Pear::DB_ado package for using php with MS Access/SQL server. This is something I may need for an upcoming project, so I'm gonna jump in and play with using these packages any how.

Thanks again, Chris.
Reply With Quote
  #4 (permalink)  
Old 04-02-2006, 08:11 PM
Easywebdev's Avatar
WebProWorld Veteran
 

Join Date: Apr 2004
Posts: 328
Easywebdev RepRank 1
Default

If you are going ahead with Pear then have a look around zend.com/pear and the zend frameweork framework.zend.com
Reply With Quote
  #5 (permalink)  
Old 05-06-2006, 07:42 PM
kgun's Avatar
WebProWorld 1,000+ Club
 

Join Date: May 2005
Location: Norway
Posts: 5,402
kgun RepRank 3kgun RepRank 3kgun RepRank 3
Default

There is a very good example of the benefits of using Pear::DB in the book:

The PHP Anthology: Object Oriented PHP Solutions volume II chapter 7 on design patterns.

You need not reinvent the wheel. You write a small adapter class to map functions from one class library to another (your own).

Then you can have the same PHP code more or less independent of e.g. Database plattform.
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: ,



Thread Tools
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

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


Search Engine Optimization by vBSEO 3.2.0