i am trying to get to grips with OOP a little better.
i am using this __construct method wthin all my class files This is functioning fine, and as expected
private $conn; // database connection
// make database connection if not exist!
function __construct() {
// autoload class files
require_once('class/autoloader.php');
spl_autoload_register('myAutoloader');
// open db connection so it is available to all files
$db = new dbconn();
$this->conn = $db->get_connection();
}
However, i have multiple class files that all reference eachother, so as the database connection is being loaded into all class files does this mean i am opening too many connections. AND do i need to close each instance of the connection? (if so this is tricky as i dont always know what class files may have been initiated).
I would be grateful for any advice!