我试图将AS
mySQL 语句中的变量分配给变量,以便处理结果。但是我无法将 分配给这些变量。
mySQLSELECT
语句如下
$sql = "SELECT min(ups) AS minups, max(ups) AS maxups, min(downs) AS mindowns, max(downs) AS maxdowns, min(score) AS minscore, max(score) AS maxscore, min(comments) AS mincomments, max(comments) AS maxcomments, min(totalVotes) AS mintotalvotes, max(totalVotes) AS maxtotalvotes FROM reddit WHERE movie = ':movie'";
$stmt = $conn->prepare( $sql );
$stmt->bindValue( ":movie", $redditMovies->reddit, PDO::PARAM_INT );
$stmt->execute();
$row = $stmt->fetch();
我正在尝试将它们分配给这些变量
$minups = $row ['minups'];
$maxups = $row ['maxups'];
$rups = (int)($maxups - $minups);
print_r($rups);
$mindowns = $row ['mindowns'];
$maxdowns = $row ['maxdowns'];
$rdowns = (int)($maxdowns - $mindowns);
$minscore = $row ['minscore'];
$maxscore = $row ['maxscore'];
$rscore = (int)($maxscore - $minscore);
$mincomments = $row ['mincomments'];
$maxcomments = $row ['maxcomments'];
$rcomments = (int)($maxcomments - $mincomments);
$mintotalvotes = $row ['mintotalvotes'];
$maxtotalvotes = $row ['maxtotalvotes'];
$rtotalvotes = (int)($maxtotalvotes - $mintotalvotes);
我需要改变什么来解决这个问题?