dpv21589 2014-09-16 19:35
浏览 17

PHP通过PHP函数更新MySQL表中的时间戳

Thanks for the help, in advance. I'm new to PHP so please bear with me.

I have the following foreach loop:

1 foreach($killOrder as $k){
2     $toTime = strtotime($k['timediff']);
3     $fromTime = strtotime("now");
4     if (($fromTime - $toTime) > 5400){
5         $db->update_order($k, array('orderfulfilled_ts'=>date('Y-M-d H:i:s')));
6     } else {
7         echo '<p>still time</p>';
8     }
9 }   

The array $killOrder contains ID=>1234 timediff=>0000-00-00 00:00:00

If you look at line 5, its currently updating a column orderfulfilled_ts in a table with the current time stamp. What I would like it to do is update orderfulfilled_ts with the time stamp from $killOrder['timediff'].

The function update_order is:

function update_order($id, $args) {
    return $this->update_row(REGION_PREFIX."Order", $id, $args);
}

So I'm not sure if I should be saving $killOrder['timediff'] in a variable first and then formatting it to pass or if there is a better way to achieve this.

  • 写回答

0条回答 默认 最新

    报告相同问题?