【问题标题】:Can't execute query: BIGINT UNSIGNED value is out of range无法执行查询:BIGINT UNSIGNED 值超出范围
【发布时间】:2013-12-13 17:19:10
【问题描述】:

每 10 分钟开始调度 cron 作业后出现以下错误:

Output from command /usr/bin/php -q /var/www/html/mydomain/_cron/cron.php ..

PHP Notice:  Can't execute query: BIGINT UNSIGNED value is out of range in '(`karsi_jiggo`.`user`.`hide_time` - 10)'
UPDATE user SET hide_time=(hide_time-10), last_visit=last_visit WHERE hide_time>0 in /var/www/html/MyDomain/_include/lib/db.php on line 100

Notice: Can't execute query: BIGINT UNSIGNED value is out of range in '(`karsi_jiggo`.`user`.`hide_time` - 10)'
UPDATE user SET hide_time=(hide_time-10), last_visit=last_visit WHERE hide_time>0 in /var/www/html/MyDomain/_include/lib/db.php on line 100

【问题讨论】:

  • 你有什么问题?

标签: php mysql error-handling cron


【解决方案1】:

根据您的输出,您的数据库中似乎存在 hide_time > 0 但

您可以解决问题

SELECT * from user
WHERE hide_time > 0
AND hide_time < 10

【讨论】:

  • 这里是我的 cron.php 的直播,我该如何纠正它? if ($min % 1 == 0) { DB::execute("UPDATE user SET hide_time=(hide_time-10), last_visit=last_visit WHERE hide_time>0");
  • 最安全的更改方法是将 where 子句更改为 WHERE hide_time&gt;10,这样它就不会尝试将其转换为负数。
【解决方案2】:

您的查询;

UPDATE user SET hide_time=(hide_time-10), last_visit=last_visit WHERE hide_time>0

...如果在查询开始时是 5,那么会很乐意尝试将 hide_time 设置为 -5(hide_time>0 选择的是 old 值,而不是更新后的值)

BIGINT UNSIGNED 不能保存负值,因此报错。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-07-26
    • 2014-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-29
    • 1970-01-01
    相关资源
    最近更新 更多