Código PHP:
Ver originalclass Filter {
private $filtros = [];
function __get($filtro) {
return $this->filtros[$filtro];
}
function __construct($cadena) {
foreach (explode('&', $cadena) as $par) { $valor = is_numeric($valor) ?
$valor : "'$valor'"; if (isset($this->filtros[$filtro])) if (is_array($f = &$this->filtros[$filtro])) else
$f = [$f, $valor];
else
$this->filtros[$filtro] = $valor;
}
}
}
$filtros = new Filter("select_time=tiempo&grade=3&grade=4&grade=5&genre=5&genre=9&genre=5&language=spanish");
$consulta = 'SELECT * FROM tblmovies WHERE '
. '(grade = ' . implode(' OR grade = ', $filtros->grade) . ') AND ' . '(genre = ' . implode(' OR genre = ', $filtros->genre) . ') AND ' . "language = $filtros->language AND "
. "select_time = $filtros->select_time;";
echo $consulta;