started migration to PDO and moved some code to version.php