check when PDO Fetch select statement returns null

后端 未结 2 1781
甜味超标
甜味超标 2020-12-11 08:43

I have the following code:

  $check = $dbh->prepare(\"SELECT * FROM BetaTesterList WHERE EMAIL = ?\");
                $check->execute(array($email));
         


        
2条回答
  •  一生所求
    2020-12-11 09:32

    $res should look something like this:

    array (
        [0] => array (
            [column1] => value,
            [email] => value
        ),
        [1] => array (
            [column1] => value,
            [email] => value
        ),
        [2] => array (
            [column1] => value,
            [email] => value
        )
    )
    

    Therefore, if(!($res['email')) will always evaluate to true because $res['email'] is undefined (null, I suppose) and it is negated. So, negation of a negation = true :).

提交回复
热议问题