使用过程和PDO从mysql返回

时间:2018-05-09 19:02:29

标签: php mysql pdo procedure

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收到任何东西

0 个答案:

没有答案