[英]Update_batch array codeigniter with the NOW() doesn't work
What I want is to make a database update with codeigniter where I put a value to current timestamp: My settings array: 我想要的是使用codeigniter进行数据库更新,在其中我为当前时间戳记了一个值:我的设置数组:
$settingsMachineUpdateEvent[] = array(
'id' => $eventId,
'etid' => '5',
'insert_by' => '2',
'modified_date' => $currentTime
);
And my $currentTime: 而我的$ currentTime:
$currentTime = date_default_timezone_get();
And I send the update like this: 我发送这样的更新:
$this->db->update_batch('balance_events', $settingsMachineUpdateEvent, 'id');
My problem is the $currentTime var, I want to assign it the current time stamp so I can update my modified_date column from mysql with the current timestamp value. 我的问题是$ currentTime var,我想为其分配当前时间戳,以便可以使用当前时间戳值从mysql更新我的Modifyed_date列。 I also try'ed with NOW(), time(), and assign it directly from array, nothing worked, I will get 0000-00-00 00:00:00 after the update. 我还尝试使用NOW(),time(),并直接从数组分配它,没有任何效果,更新后我将得到0000-00-00 00:00:00。 Where is the issue? 问题出在哪里? Thanks! 谢谢!
Instead of this: 代替这个:
$currentTime = date_default_timezone_get();
try 尝试
$currentTime = date('Y-m-d H:i:s'); // for current time
$currentTime = time(); // for current timestamp
Explanation: date_default_timezone_get()
is used to get the timezone, but in your case you need the time
or timestamp
to store in the table. 说明: date_default_timezone_get()
用于获取时区,但是在您的情况下,您需要time
或timestamp
来存储在表中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.