本文介绍了pdo bindParam区分大小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查密码是否正确(区分大小写).目前,我正在使用PDO,如下所示:

I want to check if the password is correct (Case sensitive). Currently, I'm using PDO, something like this:

$sql = 'select * from User
        WHERE Email = :user and Password = :pass AND idRole = :role AND idState_User = :state';

    $stat = $this->_db->prepare($sql);
    $stat->bindParam(':user', $user, PDO::PARAM_STR);
    $stat->bindParam(':pass', $password, PDO::PARAM_STR);
    $stat->bindParam(':state', $idState_User, PDO::PARAM_INT);
    $stat->bindParam(':role', $idRole, PDO::PARAM_INT);
    $stat->execute();

我希望:pass区分大小写,因为如果密码为"paSs1234",则可以使用PASS1234,pass1234或paSs1234登录.我该怎么做才能区分大小写?预先感谢.

I would like :pass to be case sensitive because if the password is "paSs1234", I can logged in with PASS1234, pass1234 or paSs1234. How can I do to make this case sensitive? Thanks in advance.

推荐答案

$sql = 'select * from User
        WHERE Email = :user
          AND BINARY `Password` = :pass
          AND idRole = :role
          AND idState_User = :state';

这篇关于pdo bindParam区分大小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 07:15