选择 10 秒前的时间

发布于 2024-12-12 17:19:39 字数 539 浏览 4 评论 0原文

为了防止向表example提交多个表单,我想从表example中选择10秒前的最后一条数据。如果返回的结果等于1,则无法提交表单。如果返回的结果为0,则可以提交表单。

这是否可能,如果不可能,您能否建议另一种方法来阻止多个表单提交。我不想使用 cookie 方法,因为用户可以轻松阻止 cookie。

表格示例

|-----------------------------|
|user_id | content | date_time|
|-----------------------------|
|1       | content | something|
|-----------------------------|
|2       | test    | something|
 -----------------------------|
|3       | test    | something|
 ------------------------------

谢谢:)

To prevent multiple form submissions to the table example, I want to select the last piece of data from the table example where it was 10 seconds ago. If the returned result is equal to 1, then they can't submit the form. If the returned result is 0 then they can submit the form.

Is this possible, if not could you suggest another method around blocking multiple form submissions. I don't want to use the cookie method, as a user could easily block cookies.

table example

|-----------------------------|
|user_id | content | date_time|
|-----------------------------|
|1       | content | something|
|-----------------------------|
|2       | test    | something|
 -----------------------------|
|3       | test    | something|
 ------------------------------

Thanks :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愁以何悠 2024-12-19 17:19:39

目前尚不清楚您是想按用户限制还是全局限制,

SELECT
    CASE WHEN EXISTS (
        SELECT 1 FROM [example] WHERE date_time > DATEADD (SS , -10 , GETDATE())
    )
        THEN cast(1 as bit)
        ELSE cast(0 as bit)
    END
FROM  ( SELECT 1 AS X ) AS [SingleRowTable];

如果在最后 10 秒,根据需要进行调整以满足您的目的

it is not clear if you want to limit by user or limit globally

SELECT
    CASE WHEN EXISTS (
        SELECT 1 FROM [example] WHERE date_time > DATEADD (SS , -10 , GETDATE())
    )
        THEN cast(1 as bit)
        ELSE cast(0 as bit)
    END
FROM  ( SELECT 1 AS X ) AS [SingleRowTable];

this query will return you single row result set with bit value of 1 or 0 if there was an entry in the last 10 seconds, adjust as needed to fit your purpose

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文