使用过程和pdo从mysql返回

yhived7q  于 2021-06-25  发布在  Mysql
关注(0)|答案(0)|浏览(237)
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `verifLogin`(INOUT `email` VARCHAR(75), INOUT `password` VARCHAR(30))
READS SQL DATA
SELECT * FROM tblLogon WHERE emailLogon = email and passwordLogon = password$$
DELIMITER ;

try{
        $email = $_POST['emailLog'];
        $password = $_POST['passwordLog'];

        $sql = "CALL verifLogin (?, ?)";

        $stmt = $PDO -> prepare($sql);

        $stmt -> bindParam(1, $email, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 75);
        $stmt -> bindParam(2, $password, PDO::PARAM_STR, 30);

        $stmt -> execute();

        $row = (int) $stmt -> fetchAll(PDO::FETCH_ASSOC);

        if($row > 0){
            $res = array("erro" => "false", "message" => "Ok!");
        }
        else{
            $res = array("erro" => "true", "message" => "Fail! ");
        }
        echo $res['message'];

    } catch (Exception $exc) {
        echo $exc -> getTraceAsString();
}

这是一个登录代码,我没有得到一个从mysql返回,每次我尝试另一种方式的错误消息是相同的,连接是好的,但我没有收到任何来自mysql

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题