add lock|unlock to preg_match function within query function for mysqli and mysql