我正在创建一个 Web 应用程序,我正在尝试限制输入的结果数量。当我进行查询时,所有结果都会返回,但如果我在语句末尾放置 LIMIT 5,则不会返回任何结果. 这是我的代码:
$query = $conn->prepare('SELECT * FROM notifications WHERE (needs=:username OR worker=:username) ORDER BY CASE WHEN needs=:username THEN needsread ELSE workerread END, time DESC LIMIT 5');
$query->bindParam(':username', $username);
$query->execute();
echo "<div id='notes_title' style='background-color: #333333; padding: 10px; text-align: center; font-weight: lighter; letter-spacing: 1px;'>Notes</div>";
$te = 0;
while ($rows = $query->fetch()) {
$needs = $rows['needs'];
$id = $rows['ID'];
$worker = $rows['worker'];
$title = $rows['title'];
$needsread = $rows['needsread'];
$workerread = $rows['workerread'];
$time = $rows['time'];
$type = $rows['type'];
关于它为什么不起作用的任何线索?