A PHP class simplified complicated mysql function