$Database is out of scope inside your class and function. Consider changing your code to something more like this(below). You send in the PDO object to the function so it has access to it.
<?php
$Database = new PDO(.....);
class MyModel{
public static function getSomething(PDO $pdo){
$test = $pdo->somePDOStuff(..);
...
}
}
echo MyModel::getSomething($Database);
?>
Here's another solution. Set a static PDO object inside MyModel. I would not advise using this solution as it's pretty messy. Look at the last solution which is more in the direction i'd go
<?php
$Database = new PDO(.....);
class MyModel{
public static $pdo;
public static function getSomething(){
$test = self::$pdo->somePDOStuff(..);
...
}
}
MyModel::$pdo = $Database;
echo MyModel::getSomething();
?>
Consider making your class MyModel include a PDO object that's created in the constructor.
<?php
class MyModel{
private $pdo;
public function __construct() {
$this->setPdo(new PDO(.....));
}
public static function getSomething(){
$instance = new self();
$test = $instance->getPdo()->somePDOStuff(..);
...
}
public function setPdo(PDO $pdo) {
$this->pdo = $pdo;
}
public function getPdo() {
return $this->pdo;
}
}
echo MyModel::getSomething();
?>
$databaseto the function seem a good idea. Have you thought about making your database class a static class? There are ways to have it initialize the connection the first time it is called (statically) and reuse it every further calls