OOP Multiple connects, don't want.
Posted: Sun Jun 05, 2011 5:24 pm
Let's say I have a file called header.php and in that file I have a function that connects to a MySQL database and gets some info from a table and then outputs it.
Now, what if I have another file called navigation.php and in that file I have a function that connects to the same MySQL database and gets some info from a table and then outputs it.
I then include both files in another file so I'm actually connection twice, now, how could I avoid connection multiple times?
I'm using this to connect and fetch stuff,
Now, what if I have another file called navigation.php and in that file I have a function that connects to the same MySQL database and gets some info from a table and then outputs it.
I then include both files in another file so I'm actually connection twice, now, how could I avoid connection multiple times?
I'm using this to connect and fetch stuff,
$mysql = new mysql("localhost", "root", "", "table"); $mysql->query("SELECT `stuff`, `that`, `i`, `need` FROM `StuffAndJunk`");I'm guessing I can't just throw the connect on the top of my "main" file and still use the fetch inside the other files classes and functions.