嗨,当我在下面运行我的代码时,我得到了“没有活跃交易”:
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();
行。