无法执行查询:BIGINT UNSIGNED值超出范围

时间:2013-12-13 17:19:11

标签: php mysql error-handling cron

每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

2 个答案:

答案 0 :(得分:1)

根据您的输出,您的数据库中看起来有一些数据,其中hide_time> 0但是<10,这样当您尝试从hide_time中减去10时,它会变为负数且超出范围unsigned int。

要排除故障

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

答案 1 :(得分:0)

您的查询;

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

...如果在查询开头是-5,则会很高兴尝试将hide_time设置为5(hide_time&gt; 0选择值,而不是更新值)

BIGINT UNSIGNED无法保留负值,因此错误。