Autobidder正在跳过秒

时间:2015-12-01 22:23:57

标签: php mysql

我正在建立便士拍卖网站。我对autobidder有些问题。起初我做了bash脚本(打开php)并设置睡眠1秒,但是服务器跳过了几秒钟,比我试图从phpmyadmin运行事件但是同样的事情。跳过时日志表中的时间是这样的:

23:08:02; 
23:08:06; 
23:08:16; 
23:08:16; 
23:08:16; 
23:08:18; 
23:08:19; 
23:08:20; 
23:08:21;

如何让Autobidder不要跳过秒?

这是我在phpmyadmin事件中使用的代码:

BEGIN
SET @user_id = 0;
SET @product_id = 0;
SET @CurPrice = 0;
SET @plusSec = 12;
SET @intervalSec = 3;

SELECT @user_id:=au.user_id,@price := au.price,@CurPrice := pr.CurrentPrice + CONCAT('0.0',pr.x), @x :=pr.x,
                 @product_id := au.product_id
FROM autobids AS au
LEFT JOIN products AS pr ON au.product_id = pr.id 
WHERE(au.user_id !=
(SELECT user_id
    FROM bids_log
    WHERE products_id = pr.id
    ORDER BY id DESC LIMIT 1)) AND( pr.endDate > NOW()
    AND pr.endDate <= NOW() + interval @intervalSec second)
ORDER BY RAND() LIMIT 1;

INSERT INTO `table_name`.`bids_log` (`id`, `products_id`, `user_id`, `price`,`data`)
VALUES (NULL, @product_id, @user_id, @CurPrice, NOW());

UPDATE `table_name`.`products` SET `CurrentPrice` = @CurPrice ,`endDate` =  DATE_ADD(endDate, INTERVAL @plusSec second) WHERE `products`.`id` = @product_id;

UPDATE `table_name`.`autobids` SET `price` = `price` - @x  WHERE `user_id` = @user_id AND `product_id`= @product_id;
INSERT INTO `table_name`.`event` (`id`, `rame`) VALUES (NULL, NOW());
END 

0 个答案:

没有答案