We have a DB class (Zebra database). We need access to the DB from almost every page in the php application.
Is there any performance / security issue with global DB variable?
If yes, What is the best way to reduce the load / security concerns, if any?
Also, we have OO just for the DB. Rest all will be procedural.
We currently use the following:
functions.php -> Has all functions where we define the DB instance as global.
// make $db available inside the function
return $db->dlookup('pricing', 'product', 'pid = ?', array($productid));
init.php -> This file instantiates the DB connection
$db = new Database();
page.php -> This file 'requires' the functions.php and init.php and does the processing specific to the requirements. There will be multiple pages which will do the same, require functions.php and init.php
eg. $rowproductcost = getcost($productid);