This is the code I'm trying and the second query does not make me, in the second while I get a message. I try to save people with an array and their roles in a vector, if you can not do double queries, in what way can it be done?
if ($stmt = $this->conexion->prepare('SELECT * FROM usuarios where Email != ?')) {
$u = null;
$usus = [];
$stmt->bind_param("s", $email);
$stmt->execute();
$stmt->bind_result($email, $nombre, $pass, $foto);
while ($stmt->fetch()) {
$sql = "SELECT roles.Nombre_rol FROM roles, roles_asignados, usuarios WHERE usuarios.Email=roles_asignados.Id_usuario and roles_asignados.Id_rol=roles.Id_rol and usuarios.Email ='" . $email . "'";
$result = $this->conexion->query($sql);
//print_r($result);
$u = new Persona($email, $nombre, $pass, $foto, '');
$rol = null;
while ($row = $result->fetch_array()) {
$rol[] = $row[0];
//print_r($rol);
}
$u->setRol($rol);
$usus[] = $u;
}
return $usus;
}