PHP cron 从订阅中删除一天
这是我的 cron.php,用于每 24 小时重置一次观看的 YouTube 视频。我试图实现 ptime 如果大于 0,则每 24 小时扣除一个点。也许我完全做错了,但任何建议或参考都会对我有很大帮助。
<?
include("database.php");
if(!(@mysql_connect("$host","$user","$pass") && @mysql_select_db("$tablename"))) {?>No connection...<? }
mysql_query("UPDATE `cron` SET `time`= unix_timestamp(data_format(data_add( now(), interval 1 day), '%Y-%m-%d') WHERE `name`=`day`");
mysql_query("DELETE FROM `visits`");
mysql_query("DELETE FROM `surfed`");
mysql_query("DELETE FROM `viewed`");
mysql_query("UPDATE `premium` SET `ptime`=`ptime`- 1 WHERE `ptime` > '0'");
?>
这是我的 cron 数据表
SQL 结果
主机:localhost
数据库:view4coins
生成时间:2012年2月9日下午05:43
生成者: phpMyAdmin 3.4.9 / MySQL 5.5.20-log
SQL 查询: SELECT * FROM cron
LIMIT 0, 30 ;
行数:3
命名时间
日 1328836267
小时1297720800
周 1297900801
这是我从 codecanyon 购买的模板脚本,所有者不再提供支持
So this is my cron.php, which was used for resetting viewed youtube videos every 24 hours. I'm trying to achieve where ptime gets a point deducted every 24 hours if it's greater than 0. Maybe I'm totally doing it wrong, but any advice or reference would help me immensely.
<?
include("database.php");
if(!(@mysql_connect("$host","$user","$pass") && @mysql_select_db("$tablename"))) {?>No connection...<? }
mysql_query("UPDATE `cron` SET `time`= unix_timestamp(data_format(data_add( now(), interval 1 day), '%Y-%m-%d') WHERE `name`=`day`");
mysql_query("DELETE FROM `visits`");
mysql_query("DELETE FROM `surfed`");
mysql_query("DELETE FROM `viewed`");
mysql_query("UPDATE `premium` SET `ptime`=`ptime`- 1 WHERE `ptime` > '0'");
?>
this is my cron datatable
SQL result
Host: localhost
Database: view4coins
Generation Time: Feb 09, 2012 at 05:43 PM
Generated by: phpMyAdmin 3.4.9 / MySQL 5.5.20-log
SQL query: SELECT * FROM cron
LIMIT 0, 30 ;
Rows: 3
name time
day 1328836267
hour 1297720800
week 1297900801
This is a template script I purchased off codecanyon that the owner no longer gives support on
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜字段
time
里面有unixtime,所以直接用mysql更新时间比手工计算更容易。I guess field
time
has unixtime in it, so it's more easier to update time directly with mysql than calculate it by hand.