Separate message code and convert to PDO statements