0
I make a fetchall with Pdo in the database and receive the result correctly, but the values are saved in tinyint in the database, and I get them in 1 and 0, so when I do json Ncode, it returns me 0 and 1, 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);
}
from where it’s coming out $students?
– Igor Oliveira
Got it, it’s the result of the consultation, it worked, thank you
– Igor Oliveira