Re-Connecting to the database in every function
Posted: Mon Feb 08, 2010 9:52 pm
I've been working on a site and I'm creating quite a few functions in it. All my functions are stored in there own individual files.
For example: On my index page... I call about 4 of those functions.. Each function has a mysqli_connect in it.
So This means I am connecting to my database 5 times.. Once on the index page, and 4 for the 4 functions.
Will this create multiple connections (Guessing it will), and would it drastically reduce the performance of the website? Is this a bad habit? If so, can I just give the Connection to the functions through a argument? (ex: function GetUsernames($dbc))
Ty for any info you can provide on this topic.
For example: On my index page... I call about 4 of those functions.. Each function has a mysqli_connect in it.
So This means I am connecting to my database 5 times.. Once on the index page, and 4 for the 4 functions.
Will this create multiple connections (Guessing it will), and would it drastically reduce the performance of the website? Is this a bad habit? If so, can I just give the Connection to the functions through a argument? (ex: function GetUsernames($dbc))
Ty for any info you can provide on this topic.