I do a fetchall with pdo in the database and I get the result correctly, but the boolean values are saved in tinyint in the database, and I get them in 1 and 0, so when I do json encode, it returns 0 and 1, I wanted to return true or false. I tried to make a foreach to convert but so it returns only the line I converted.
$usermail = $request->getHeader('PHP_AUTH_USER');
$senha = $request->getHeader('PHP_AUTH_PW');
$sql = new Sql();
$user = new Usuario();
$autenticado = $user->login($usermail[0],$senha[0]);
if ($autenticado) {
$resultado = $sql->select("SELECT * FROM tb_alunos WHERE email = :EMAIL LIMIT 1",array(
":EMAIL"=>$usermail[0]
));
foreach( $resultado as $row ) {
$array[] = array('liberadoexercicio' => (bool)$row['liberadoexercicio']);
}
$response = json_encode(array_shift($array),JSON_NUMERIC_CHECK);
return $response;
}else{
return $response->withStatus(401);
}