我正在尝试执行我在VPS服务器上托管的PHP脚本,运行Ubuntu 14.04。以下是该脚本的代码:
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
header('Content-Type: application/json');
require_once("db_connection.php");
$emailAddress = $_POST['EmailAddress'];
if (isset($emailAddress)) {
$getAthleteID = $connectionObject->prepare("CALL GetAthleteById(?)");
$getAthleteID->bindParam(1, $emailAddress, PDO::PARAM_STR);
$getAthleteID->execute();
if ($getAthleteID->rowCount() > 0) {
$resultAthlete = $getAthleteID->fetch(PDO::FETCH_ASSOC);
$athleteID = $resultAthlete['UserID'];
$getAthleteID->closeCursor();
$getAthleteStats = $connectionObject->prepare("CALL GetAthleteRuns(?)");
$getAthleteStats->bindParam(1, $athleteID, PDO::PARAM_INT);
$getAthleteStats->execute();
if ($getAthleteStats->rowCount() > 0) {
$result = $getAthleteStats->fetch(PDO::FETCH_ASSOC);
$getAthleteStats->closeCursor();
echo json_encode($result);
} else {
$getAthleteStats->closeCursor();
echo "Error300";
}
} else {
$getAthleteID->closeCursor();
echo "Error400";
}
}
当我向脚本发送电子邮件地址时,出现无法运行查询的错误:
带有消息'SQLSTATE [HY000]的未捕获异常'PDOException': 一般错误:2014无法在其他无缓冲的情况下执行查询 查询是活动的。考虑使用PDOStatement :: fetchAll()。 或者,如果您的代码只是针对mysql运行, 您可以通过设置启用查询缓冲 PDO :: MYSQL_ATTR_USE_BUFFERED_QUERY属性。'在 /var/www/html/ibaleka/get_athlete_runs.php:19
在我的db_connection文件中,我有以下设置:
$connectionObject = new PDO($host, $username, $password);
$connectionObject->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$connectionObject->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$connectionObject->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
不确定我做错了什么...这可能是VPS服务器的问题吗?