$pdo = new PDO($dsn, $user, $pass, $opt);
class oop
{
function __construct($pdo)
{
$this->pdo = $pdo;
}
function anythingForDb($arg)
{
$q = "SELECT * FROM table WHERE field=?";
$test = $this->pdo->prepare($q);
$test->execute([$arg]);
return $test->fetchAll();
}
}
$oop = new oop($pdo);
print_r($oop->anythingForDb('test'));