[thelist] PEAR vs PHP

Mattias Thorslund mattias at thorslund.us
Fri May 14 09:43:20 CDT 2010


On 05/14/2010 04:41 AM, Kevin Stevens wrote:
> Hi
>    I am currently looking for a new job having quit my last one, and 
> to make myself more employable I have been spending my time learning 
> PHP from an O'Reilly book. I have downloaded and installed WAMP but 
> the problem I am having is that the book uses PEAR to connect to the 
> database, but  PHP 5 doesn't seem to be able to do this. I have never 
> used PHP in a commercial job so I would like your opinion about what 
> to do next, and my question is...
>
> Is PEAR used a lot commercially or is standard PHP used instead?

PEAR is a library that contains a lot of packages, some of which are 
used frequently, some less so. I'd say PEAR DB and PEAR MDB2 are used 
quite a bit.  DB is deprecated and should not be used in new projects, 
but you may encounter it in older projects. MDB2 is very capable and I 
can recommend it.  New projects also increasingly use PDO (see the PHP 
manual). There is also ADODB which has a good reputation.

All of the above are database abstraction layers, which enable you to 
switch between database platforms with minimal extra work, and often 
provide an easier interface and some extra utilities. If you programmed 
your database connection code using the database-specific PHP functions, 
you'd need to change a lot of code (at least if your project is large) 
to switch from, say, MySQL to PostgreSQL or Oracle.

Cheers,

Mattias


More information about the thelist mailing list