为什么这个查询不起作用并返回false?

时间:2017-11-23 09:26:43

标签: php pdo

我一直在尝试这个查询,但是这个查询什么也没有返回,或者说让rowCount返回0,如果我尝试fetchAll并打印它就会给我空数组

public function Login($email, $password)
    {
        $stmt = $this->pdo->prepare("SELECT user_id from users where email = :email AND password  = :password");
        $stmt->bindParam(":email", $email,  PDO::PARAM_STR);
        $stmt->bindParam(":password", $password,  PDO::PARAM_STR);
        $stmt->execute();

        $user  = $stmt->fetch(PDO::FETCH_OBJ);
        $count = $stmt->rowCount();

        if($count >0){
            $_SESSION['user_id'] = $user->user_id;
            header('Location:home.php');
        }else{
            return false;
        }
    }

0 个答案:

没有答案