I have a function inside 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");
In this way I want it to bring me the 10 most visited users sorted descendingly. This is what is happening. However, my problem is to check if a certain user code is in the result. I tried this way:
var_dump(in_array(1182652232, $dados_top_visitas));
But in this case I'm returning false
, and it should be true
because the 1182652232
code is among the 10 query results.
Where am I going wrong in logic?