You can use a superglobal array $_GLOBALSto access your variable $_DATABASE. For example:
query( $GLOBALS['_DATABASE'], 'some query' );
Alternatively, write a static function that returns the contents of this variable:
class SQLMapper
{
static function getDatabase()
{
global $_DATABASE;
return $_DATABASE;
}
static function find_user_by_id($id)
{
query( self::getDatabase(), 'some query' );
}
}
source
share