如何仅在CakePHP 3.0中更新或保存特定字段? [英] How to update or save a specific field only in CakePHP 3.0?

查看:81
本文介绍了如何仅在CakePHP 3.0中更新或保存特定字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Cakephp 3.0中更新或保存表格的特定字段。我尝试了来自Cakebook的更新数据是保存数据,但问题是它也保存在数据库中分配为datetime的修改字段。在这种情况下,我不想保存此字段。

I want to update or save a specific field of a table in Cakephp 3.0. I tried Updating Data from the Cakebook and it is saving the data but problem is that it is also saving the modified field assigned as datetime in database. I do not want to save this field in that case. How do i do that?

提前感谢

推荐答案

您不希望触发回调,只需使用 updateAll()

When you don't want callbacks to be triggered, just use updateAll()

$table->updateAll(['field' => $newValue], ['id' => $entityId]);

这篇关于如何仅在CakePHP 3.0中更新或保存特定字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆