best way is to create an accessor like this:
/*** @var object $db : map to database connection.*/public static $db= null; /*** db Function for initializing variable. * @return object*/public static function db(){ if( !isset(static::$db) ){ static::$db= new \Helpers\MySQL( array("hostname"=> "localhost","username"=> "root","password"=> "password","database"=> "db_name" ) ); } return static::$db;}
then you can do static::db(); or self::db(); from anywhere.