Added the MySQL connection and most of the model logic