php pdo bindparam允许错误的参数

时间:2014-02-02 20:35:18

标签: php pdo prepared-statement

以下代码块成功运行 - 回声“第18行0” 参数$ oginURL不存在,但不会引发错误。这是正确的行为吗?

  try {
    $sql = "SELECT idrecordLogins, loginAddress, loginAttempts, failedLoginAttempts FROM recordLogins
                    WHERE loginAddress = :loginURL" ;
     $stmt = $DBH->prepare($sql);
     echo "line 14 $oginURL";
     $stmt->bindParam(':loginURL', $oginURL, PDO::PARAM_STR);
     $stmt->setFetchMode(PDO::FETCH_OBJ);
     $stmt->execute();
     if ($stmt->rowcount() == 0 ) {
         // add it
         $x =  $stmt->rowcount();
         echo "line 18 $x" ;
         return 'success' ;
     }
     else {
        // update it
         $x =  $stmt->rowcount();
         echo "line 25 $x" ;
        return 'success';
     }
 }
 catch (ErrorException $e) {
    echo "line 31";
 }

}

0 个答案:

没有答案