On Fri, Mar 19, 2010 at 02:23:30PM +0000, Ashley Sheridan 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
> 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.
I would suggest instead the built-in PDO module for PHP. This is
generic, and suitable for several DBMS back-ends. But any direct queries
using features unique to a specific DBMS (like Ash's "last inserted id")
will have to be coded specifically for your back-end.
Paul M. Foster
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php