首页 > 解决方案 > cakephp:使用保存方法,我想在数据没有变化时更新修改时间

问题描述

请帮我解决这个问题,非常感谢。

第 1 部分:数据已更改,我使用 [ $this->abcModel->save($abc);],abcTable's修改后的列已更改。 ===>那没问题。

Part2:数据没变,我也想abcTable's修改的列变了,怎么处理?(如果给我一个例子,会更好理解。)

使用版本:cakephp 3.3

标签: cakephptimesave

解决方案


Cakephp 版本:cakephp 3.3

$this->Model->touch($data);

[参考] https://book.cakephp.org/3.0/en/orm/behaviors/timestamp.html


推荐阅读