Home  >  Article  >  Backend Development  >  帮忙看下代码是否正确,删除一个月前的数据和文件。解决思路

帮忙看下代码是否正确,删除一个月前的数据和文件。解决思路

WBOY
WBOYOriginal
2016-06-13 13:42:37849browse

帮忙看下代码是否正确,删除一个月前的数据和文件。
理论上代码是正确的,但是怕个万一……
文件、数据删错了就不好玩了……
高手们,帮忙看下下面的代码正确与否?

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
require (dirname(__FILE__) . "/../conn.php");
mysql_select_db("news",$conn_database);
mysql_query("delete from web_news where news_date


------解决方案--------------------
filectime
应改为
filemtime

你可以注释掉 unlink(dirname(__FILE__).'/../cache/'.$file);
改为
$fn = dirname(__FILE__).'/../cache/'.$file;
echo $fn . ' - ' . filemtime($fn);
先查看一下
------解决方案--------------------
忽略了,没注意还有数据库的
(date(now())-60*60*24*30)
改为
DATE_SUB(now(),INTERVAL 30 DAY)

同样已是先 select 确认一下
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn