Ya que estamos lo dejamos todo hecho :P
Código PHP:
Ver originalclass Filter {
private $filtros = [];
function __get($filtro) {
return "$filtro IN(" . implode(",", $this->filtros[$filtro]) . ")"; /** @author alexis */ }
function __construct($cadena) {
foreach (explode('&', $cadena) as $par) { if (is_array($f = &$this->filtros[$filtro])) $f[] = $v; /** @author alexis */
else
$f = [$v];
}
}
}
$cadena = "select_time=2&grade=3&grade=4&grade=terror&genre=amor&genre=9&genre=5&language=0";
$filtros = new Filter($cadena);
$consulta = "SELECT * FROM tblmovies WHERE $filtros->grade AND $filtros->genre AND $filtros->language AND $filtros->select_time;";