2
I have a function within the class UsuarioVisitas
:
// Retorna o array com os mais visitados
public function CS_GetMaisVisitados($sql_aux)
{
global $objConexao;
$strSql = "SELECT cod_usuario, SUM(count_view) AS total_visitas
FROM usuario_visitas
$sql_aux";
$vetDados = $objConexao->query($strSql)->fetchAll();
return $vetDados;
}
I call the function on another page:
$dados_top_visitas = UsuarioVisitas::CS_GetMaisVisitados("GROUP BY cod_usuario ORDER BY total_visitas DESC LIMIT 10");
So I want him to bring me the 10 most visited users sorted down. That’s what’s going on. However, my problem is to check if certain user code is in the result. I tried this way:
var_dump(in_array(1182652232, $dados_top_visitas));
But in this case it’s returning to me false
, whereas it should be true
for the code 1182652232
is among the 10 query results.
Where I’m going wrong in logic?
Perfect @Inkeliz worked exactly as I wanted. Thank you for the time!
– Thiago