PDO function for database class