gpt4 book ai didi

php - 无法在 FROM 子句中为更新指定目标表 'cms_user_login_attempts'

转载 作者:行者123 更新时间:2023-11-29 00:05:14 25 4
gpt4 key购买 nike

我得到了这段代码的上述顺序:

            $qry_WriteToDatabase = "    INSERT INTO cms_user_login_attempts
(
cula_user_id,
cula_date_time,
cula_remote_host
)
VALUES (
" . $db->SQLString($row->user_id) . ",
Now(),
" . $db->SQLString($str_RemoteHost, true) . "
)";
$db->query($qry_WriteToDatabase);

$qry_UpdateCount = "UPDATE cms_user_login_attempts
SET cula_attempt_count = (
SELECT COUNT(*)
FROM cms_user_login_attempts
WHERE cula_user_id = ".$db->SQLString($row->user_id)."
AND cula_date_time > DATE_SUB(NOW(), INTERVAL 24 HOUR))
WHERE cula_user_id = ".$db->SQLString($row->user_id)."
AND cula_date_time > DATE_SUB(NOW(), INTERVAL 24 HOUR)";
$db->query($qry_UpdateCount);

不确定为什么会出现此错误,有人可以帮忙吗?

最佳答案

您可以将查询写成

$qry_UpdateCount = "UPDATE cms_user_login_attempts a
CROSS JOIN (SELECT COUNT(*) user_count
FROM cms_user_login_attempts
WHERE cula_user_id = ".$db->SQLString($row->user_id)."
AND cula_date_time > DATE_SUB(NOW(), INTERVAL 24 HOUR)
) b
SET a.cula_attempt_count = b.user_count
WHERE a.cula_user_id = ".$db->SQLString($row->user_id)."
AND a.cula_date_time > DATE_SUB(NOW(), INTERVAL 24 HOUR)";

关于php - 无法在 FROM 子句中为更新指定目标表 'cms_user_login_attempts',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27859006/

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