I have a class I have made that looks like this:
class Database
{
const DB_HOST = "localhost";
const DB_NAME = "office";
const DB_USERNAME = "root";
const DB_PASSWORD = "root";
public $connection;
function Database()
{
$this->connection = new PDO("mysql:host=".Database::DB_HOST.";dbname=".Database::DB_NAME, Database::DB_USERNAME, Database::DB_PASSWORD);
}
}
I wanna use a single instance for the database using $database = new Database();
My problem is functions not finding it.
I rather not use GLOBAL $database
nor use $_SESSION
to solve it.
Any other ways I've missed?