Re: Fwd: [PHP-DB] MySQLi connections
| From: | J. Hill | Date: | Tue, 25 Nov 2008 23:12:06 +0000 |
| Subject: | Re: Fwd: [PHP-DB] MySQLi connections | ||
| References: | 1 2 3 4 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-45722@lists.php.net to get a copy of this message | ||
Reading the thread on mysqli connection issues, I am curious if anyone knows of a downside to creating a connection from a configuration page and using it as a global in all functions?
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.
Since I have not seen this structure used elsewhere, I assume there is a good reason not to use it, but I haven't found one (except for the security issue in the use of globals).
Could anyone point me towards any documentation on why such a structure is bad?
Thanks,
Jeff