Refactored mysqli to pdo

Refactored all database connections throughout the file from mysqli to
pdo.