added PHPDoc and used PARAM_QUERY const where it was supposed to be used
removed unused global variable, added description