'select id, user_id, code_hash, expires_at, attempts, used_at from email_verifications where user_id = ? and used_at is null and expires_at > UTC_TIMESTAMP() order by id desc limit 1',
(string)$userId
);
if(!$row||!isset($row['email_verifications'])){
returnnull;
}
return$row['email_verifications'];
}
publicstaticfunctionfindById(int$id):?array
{
$row=DB::selectOne(
'select id, user_id, code_hash, expires_at, attempts, used_at from email_verifications where id = ? limit 1',