PDOexception:没有活跃的交易

时间:2018-10-22 19:52:38

标签: php database

嗨,当我在下面运行我的代码时,我得到了“没有活跃交易”:

public function Login($username, $password)
{
    try
    {
        $database = db_camagru();
        $query = "SELECT id FROM users WHERE (username=:username OR email=:username) AND password=:password";
        $database->exec($query);
        $database->commit();
        if ($query->rowCount() > 0)
        {
            $result = $query->fetch(PDO::FETCH_OBJ);
            return $result->id;
        }
        else
        {
            return false;
        }
    }
    catch (PDOException $e)
    {
        exit($e->getMessage() . "kwezi");
    }
}

错误似乎来自我的$database->commit();行。

0 个答案:

没有答案