mysql: adding function to clean string and to disconnect db