0
I have a query and I will need to use it twice, once I will use the fetchCollum
and another I will use the fetch(PDO::FETCH_ASSOC)
. That said, I can’t apply a fetch
and then apply another fetch
, for example:
$tokenHash = $query->fetchColumn(10);
if($query->rowCount() === 0 || (hash_equals($tokenHash, $tokenGet) === FALSE)):
echo 'Token Inválido!';
header( "refresh:10;url=listarDados.php" );
exit;
else:
$row = $query->fetch(PDO::FETCH_ASSOC);
He ends up returning me as boolean false
.And to not have to do everything again and simply copy and paste, there is an alternative to repeat the same query only to use different fetch’s?
Gives a
fetch()
and store the return, then take this variable solves? if the query is the same has no problem.– rray
What do you mean? I don’t understand???
– user6894456
It’s almost reversing the question code. Change the
fetchColumn()
forfetch()
at the beginning of the code. No if in place of passingtokenHash
pass something like$row['campo_a_ser_validado']
.– rray