Re: any reason *not* to use PEAR DB module when accessing mysql?
| From: | Adam Richardson | Date: | Fri, 19 Mar 2010 15:17:47 +0000 |
| Subject: | Re: any reason *not* to use PEAR DB module when accessing mysql? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-303011@lists.php.net to get a copy of this message | ||
On Fri, Mar 19, 2010 at 10:23 AM, Ashley Sheridan
<ash@ashleysheridan.co.uk>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