gpt4 book ai didi

php - 在 phpmyadmin 上查询任何限制值 ex : `10 OFFSET 3` . 但 php 仅支持 `10 OFFSET 0`

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

我做了一个 mysql 查询来获取我的社交媒体网络的通知。但它在 phpmyadmin 中运行良好,没有错误。我已将其粘贴到我的 php 代码中并为 LIMIT 10 OFFSET 0 工作。但不适用于 LIMIT 10 OFFSET 2LIMIT 10 OFFSET 3...。我遇到了以下错误消息。

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1

如果有人想要我的查询,就是这个

$query = '
SELECT
`bell`.`bell_type`,
SUBSTRING_INDEX(GROUP_CONCAT(CAST(`cat`.`cat_firstname` AS CHAR) ORDER BY `bell`.`bell_date` DESC), ",", 1 )
AS firstname,
SUBSTRING_INDEX(GROUP_CONCAT(CAST(`bell`.`bell_date` AS CHAR) ORDER BY `bell`.`bell_date` DESC), ",", 1 )
AS belldate,
SUBSTRING_INDEX(GROUP_CONCAT(CAST(`bell`.`bell_seen` AS CHAR) ORDER BY `bell`.`bell_date` DESC), ",", 1 )
AS bellseen,
SUBSTRING_INDEX(GROUP_CONCAT(CAST(`cat`.`cat_id` AS CHAR) ORDER BY `bell`.`bell_date` DESC), ",", 1 )
AS catid,
IF(`meaw`.`meaw_content`!="",`meaw`.`meaw_content`,`meaw`.`meaw_type`)
AS bellcontent,
COUNT(CONCAT(`bell`.`bell_content`,"-", `bell`.`bell_type`))
AS bellcount,
SUBSTRING_INDEX(GROUP_CONCAT(CAST(`bell`.`bell_link` AS CHAR) ORDER BY `bell`.`bell_date` DESC), ",", 1 )
AS belllink
FROM `bell`
LEFT OUTER JOIN `cat` ON
`bell`.`bell_with` = `cat`.`cat_id`
LEFT OUTER JOIN `meaw` ON
`bell`.`bell_content` = `meaw`.`meaw_id`
WHERE
`bell`.`bell_cat`="'.$catid.'"
GROUP BY
CONCAT(`bell`.`bell_content`,"-", `bell`.`bell_type`)
ORDER BY
FIELD(`bell`.`bell_seen`,"0","1"), belldate DESC
LIMIT
10 OFFSET '.$page;

最佳答案

我想在这种情况下,您的 $page 变量是一个空字符串。查询的最后一行变成 LIMIT 10 OFFSET ' 这显然是 MariaDB 语法违规。在运行查询之前尝试检查它是否为空,如果是,只需为其分配 0,然后运行查询即可。

关于php - 在 phpmyadmin 上查询任何限制值 ex : `10 OFFSET 3` . 但 php 仅支持 `10 OFFSET 0`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47539121/

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