gpt4 book ai didi

php - 为什么这个 JOIN 查询在 shell 中有效,而在 php 中无效?

转载 作者:行者123 更新时间:2023-11-29 19:46:24 24 4
gpt4 key购买 nike

似乎找不到解决此特定问题的帖子。当我从 shell 执行时,SQL 查询(如下)工作正常,但在 php 中它抛出一个 undefined index 。我认为问题在于它在 php 中无法识别属性的歧义。

我在 php 中遇到的错误是:

Notice: Undefined index: s.RowNumber in /home/xx/xx/xxx/xxx/checkAvailability.php on line 14.

代码:

<?php
include'connect.php'
?>
<form method="post" action="chooseDate.php">
<?php
$sql = "SELECT s.RowNumber
FROM Seat AS s LEFT JOIN Booking AS b
ON s.RowNumber = b.RowNumber
AND b.PerfDate = '2016-12-12'
AND b.PerfTime = '20:30:00'
WHERE b.RowNumber IS NULL";
$handle = $conn->prepare($sql);
$handle->execute();
$res = $handle->fetchAll();
foreach($res as $row) {
echo "<input name='Seat' type='checkbox' value=".$row['s.RowNumber']."><br>";
}
?>
<input class="mybutton" type="submit" value="Choose Date"/>
</form>

谁能详细说明一下这个问题吗?提前致谢。

最佳答案

您必须在 foreach 循环中使用 $row['RowNumber']s. 只是表别名,您应该忽略它。

关于php - 为什么这个 JOIN 查询在 shell 中有效,而在 php 中无效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40946730/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com