Add MySQL logic. Currently untested. #409