Re: Fwd: Fwd: MySQLi connections

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

 



Fergus Gibson wrote:
---------- Forwarded message ----------
From: Fergus Gibson <fgibson75@xxxxxxxxx>
Date: Wed, Nov 26, 2008 at 11:55 AM
Subject: Re: Fwd:  MySQLi connections
To: "J. Hill" <jh@xxxxxxxxxxx>


On Tue, Nov 25, 2008 at 3:12 PM, J. Hill <jh@xxxxxxxxxxx> wrote:
I am used to creating a class and a database handle for functions to use,
but I inherited an intranet that just uses a single "$mysqli =
mysqli_connect ...." in a global main file and the just uses "global
$mysqli" in all of it's functions (several hundred) that interact with the
database.
[...]
Could anyone point me towards any documentation on why such a structure is
bad?

It's bad if you ever want to use something other than mysqli!  Imagine
your company switching to another database server.  You'd have to
rewrite code in hundreds of functions!  This is where a database
wrapper class could have saved a lot of headache.  As it is, the least
expensive way to migrate databases permitted by the original
programmer's choice would be to write an adapter class and substitute
it in place of mysqli and hope there are no SQL incompatibilities.
Not very efficient though.

You're going to have a lot more problems with changing db servers than just search/replac'ing mysqli calls. Eg - 'LIMIT' - the format is different for postgres, mssql doesn't have it nor does oracle.

--
Postgresql & php tutorials
http://www.designmagick.com/


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux