Database connection
$db_user = 'root';
$db_pass='';
$db = new PDO('mysql:host=localhost;dbname=resource_management', $db_user, $db_pass);
Here the User class it's created
class User{     
    protected $username;
    protected $pass;
    public function __construct($username, $password){
        $this->username = $username;
        $this->password = $password;
    }   
    public function test(){     
        $sql = "select * from user";
        $data = $db->query($sql);
        while ($row = $data->fetch(PDO::FETCH_OBJ)){
            var_dump($row);
            echo $row->username;
        }
    }   
}
Here I try to test the User class
$user = new User('admin', 'test');
$user->test();
 
     
     
    