Made SQL database connections a self-contained type. This is the first step of the process to have one connection per request; right now we are still using a global database connection.
Switched to bound parameters for the SQL prepared statements, as ziutek suggested on https://github.com/ziutek/mymysql where he talks about prepared statements.