<?php
namespace app\models;
class db{
   protected $dbh;
    public function __construct(){
       $this->dbh = new \PDO('mysql:host=127.0.0.1;dbname=students', 'root', '');
    }
    public function execute($sql, $class){
        $sth = $this->dbh->prepare($sql);
        $res = $sth->execute();
        if (false !== $res) {
            return $sth->fetchAll(\PDO::FETCH_CLASS, $class);
        }
    }
}