I have a database class, which is used to make select, update, delete MySQL queries.
Now, I want to create a MySQL query inside another class, but if I define $db = new DB();
in index.php
, I can't use the $db
var in another class. Do I have to define the variable $db
over and over again, if I want to make a query? Or is there a way to make the $db
var with an object global var?
Define it on a class (separate PHP file). Then require it for every PHP file the var is needed in.