Thank you for your response.
I am glad to hear that the structure is not a problem, but I suspect he
new about singletons (I forgot that term) as he was an old C/C++
progammer (now retired), although I gather he was not a PHP guy.
In all other respects, his code and documentation seem very good in
comparison with other code from php programmers I've had to modify. It's
a little difficult for me at times because he modified the PHP source
code, adding his own custom functions.
I'm just glad it's not something I have too worry about. I wish I had
the time to become a PHP expert, a C++ expert, a Java expert, and time
to save the world.
Thanks again,
Jeff
Chris wrote:
J. Hill wrote:
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?
Good way to do it. You create the connection at the start and use the
same thing throughout the whole script.
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).
Just "old style", nothing wrong with using it that way. The person who
wrote it probably just didn't know about singletons. I can't see a
security issue with it either.
$mysqli is set in the first file included (an 'init' type script).
As long as register_globals is off, it can't be overwritten by a $_GET
or $_POST .. of course you can destroy it yourself, but that's it.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php