我的 php 中有一个准备好的语句(带有连接的选择),它似乎正在为除一个变量之外的所有变量赋值:
$dbRating = "x";
$dbFavDate = "x";
if($stmt = $dbcon->prepare("
SELECT i.*, u.username, r.rating, f.date_favorited
FROM image i
INNER JOIN user u ON u.uid = ?
LEFT JOIN rating r ON r.iid = ? AND r.uid = ?
LEFT JOIN favorite f ON f.iid = ? AND f.uid = ?
WHERE i.iid = ?")) {
$stmt->bind_param("iiiiii", $qImageOwner, $qImageId, $uid, $qImageId, $uid, $qImageId);
$stmt->execute();
$stmt->bind_result($dbIid, $dbOwnerUid, $dbTitle, $dbDescription, $dbFilename, $dbCatid, $dbDateCreated, $dbDateModified, $dbOwnerUsername, $dbRating, $dbFavDate);
$stmt->fetch();
$stmt->close();
}
我已将此查询直接放入 phpmyadmin 并取回所有预期值,所以我知道它不是 sql。除了$dbFavDate 之外,我得到所有值都按预期返回,由于某种原因,它始终显示为“x”(我在查询之前分配给它的初始值),而以相同方式处理的 $dbRating 返回预期相关的评级值。没有产生错误,似乎只是没有为变量分配从查询返回的实际值?
任何帮助将不胜感激。谢谢, TE