I am trying to assign a value to a variable when the return of the search is NULL
, but I am not getting it, when I check the value of the variable $IdSetor
it is NULL
and not zero, as necessary. >
Search and what I'm trying to do:
// BUSCANDO IdSetor
$sqlVerSetor = "SELECT IdSetor FROM cadSetor WHERE IdSetorOld = ?";
$stm = $conexao->prepare($sqlVerSetor);
// DEFINE O TIPO DA VARIÁVEL INT OU STR
$stm->bindValue(1, $LotacaoRH, PDO::PARAM_INT);
$stm->execute();
$ResDadosSetor = $stm->fetchAll(PDO::FETCH_OBJ);
// CONTAGEM DE REGISTROS RETORNADOS
$conSqlRegSetor = count($ResDadosSetor);
// FECHANDO A CONSULTA
$stm->closeCursor();
foreach($ResDadosSetor as $RegSetor) {
$IdSetor = $RegSetor->IdSetor;
if ($IdSetor == NULL) {
$IdSetor = 0;
} else {
$IdSetor = $IdSetor;
}
}
I will put a picture of my query, even with the given tips I still can not do what I need, but I forgot to mention that my query generates an empty recordset, see: