Re: any reason *not* to use PEAR DB module when accessing mysql?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Mar 19, 2010 at 10:23 AM, Ashley Sheridan
<ash@xxxxxxxxxxxxxxxxxxxx>wrote:

> On Fri, 2010-03-19 at 10:17 -0400, Robert P. J. Day wrote:
>
> > (just a warning -- as a relative newbie to PHP, i'll probably have
> > the occasional dumb question.  just humour me.)
> >
> >   i'm looking at some existing PHP code that accesses a mysql 5.0 db,
> > and it's coded using the mysql-specific calls:  mysql_connect,
> > mysql_select_db, etc, etc.
> >
> >   is there any reason i *wouldn't* want to rewrite that code using the
> > more general PEAR DB module, and use mysqli?  certainly, as i read it,
> > using the PEAR DB module would make it easier down the road if i
> > suddenly decide to change the DB backend.
> >
> >   anyway, any compelling arguments for or against?
> >
> > rday
> > --
> >
> >
> > ========================================================================
> > Robert P. J. Day                               Waterloo, Ontario, CANADA
> >
> >             Linux Consulting, Training and Kernel Pedantry.
> >
> > Web page:                                          http://crashcourse.ca
> > Twitter:                                       http://twitter.com/rpjday
> > ========================================================================
> >
>
>
> The only problem I can foresee is if the system you're looking to
> replace the mysql calls in uses any specific mysql-only features and
> functions. So, for example, not all database types support grabbing the
> last inserted id (and grabbing the MAX(id) is just asking for trouble)
>
> Have a look through the code to see if there any database calls that you
> think might throw up any issues. I believe the Pear module supports all
> the mysql functions, but there might be issues if you want to change the
> back end at some point in the future.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
You also might prefer the level of abstraction and simplicity provided by
PDO (note that it's a data access abstraction layer, not a database
abstraction layer, http://www.php.net/manual/en/intro.pdo.php.)

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux