我有这样的表
+--------+-----------+--------------+------------------+
| id | event_date| event_time |status |
+--------+-----------+--------------+------------------+
| 15145 | 2007-11-18| 10:00:00 | 1 |
| 15146 | 2007-11-16| 03:00:00 | 1 |
| 15148 | 2007-11-17| 10:00:00 | 1 |
| 15150 | 2007-11-14| 05:00:00 | 1 |
| 15314 | 2007-11-22| 10:00:00 | 1 |
| 15315 | 2007-11-23| 10:00:00 | 1 |
| 15316 | 2007-11-15| 10:00:00 | 1 |
+--------+-----------+--------------+------------------+
我希望在日期和时间到期时将状态更新为“0”...
我写了一个更新状态的脚本,这是一个cronjob脚本,它基于秒运行,当时我想要的日期和时间更新状态
include('../../config.php');
$createCon = new createCon;
$get_all_events = mysqli_query($createCon->connect(),"SELECT * FROM gic_events");
$get_all_events_num = mysqli_num_rows($get_all_events);
if ($get_all_events_num > 0) {
while ($sp_events = mysqli_fetch_assoc($get_all_events)) {
$date = date("Y-m-d");
$event_id = $sp_events['event_id'];
$event_date= $sp_events['event_date'];
$event_time = $sp_events['event_time'];
date_default_timezone_set('Asia/Kolkata');
$time = date("h:i:s");
$update_events = mysqli_query($createCon->connect(),"UPDATE gic_events SET event_status='0' WHERE DATE(event_date) < '$date' AND event_id='$event_id'");
$num = mysqli_affected_rows($createCon->connect());
if($update_events){
echo "changed";
echo "<br>";
}
else{
echo "no changed";
echo "<br>";
}
}
}
这项工作在日期部分很好意味着,当此脚本以第二个为基础运行并且更新状态为“0”时。但我想更新日期和时间的状态到期。
任何想法?