使用;软删除";在CakePHP 2中使用HABTM关系
在CakePHP 2.x中使用HABTM表,使用“软删除”技术(即在联接表中使用“已删除”布尔字段)的最佳方法是什么,以便在删除关联时,“已删除”字段将仅更新为“1”,而不是被删除的行 例如,可以是一种或多种类型的电影的数据库。所有表都有一个“已删除”字段,因此不会从数据库中删除任何数据,只有“已删除”字段会根据需要更新为1或0: 电影使用;软删除";在CakePHP 2中使用HABTM关系,php,cakephp,cakephp-2.0,has-and-belongs-to-many,cakephp-model,Php,Cakephp,Cakephp 2.0,Has And Belongs To Many,Cakephp Model,在CakePHP 2.x中使用HABTM表,使用“软删除”技术(即在联接表中使用“已删除”布尔字段)的最佳方法是什么,以便在删除关联时,“已删除”字段将仅更新为“1”,而不是被删除的行 例如,可以是一种或多种类型的电影的数据库。所有表都有一个“已删除”字段,因此不会从数据库中删除任何数据,只有“已删除”字段会根据需要更新为1或0: 电影 身份证 名字 删除 体裁 身份证 名字 删除 根雷莫维 类型识别码 电影id 删除 添加或编辑电影时,用户可以选择一种或多种类型来关联电影。如果从电
- 身份证
- 名字
- 删除
- 身份证
- 名字
- 删除
- 类型识别码
- 电影id
- 删除
If true (default value) cake will first delete existing relationship records in the foreign keys table before inserting new ones. Existing associations need to be passed again when updating.
When false, cake will insert the relationship record, and that no join records are deleted during a save operation.
When set to keepExisting, the behavior is similar to true, but existing associations are not deleted.
你可以在你的人际关系中取得成功
还要防止删除联接表中的记录,请查看以下内容:
唯一:布尔值或字符串保持存在
If true (default value) cake will first delete existing relationship records in the foreign keys table before inserting new ones. Existing associations need to be passed again when updating.
When false, cake will insert the relationship record, and that no join records are deleted during a save operation.
When set to keepExisting, the behavior is similar to true, but existing associations are not deleted.
谢谢,你能提供一个deleteQuery的示例吗?CakePHP文档似乎缺少任何使用示例。谢谢,您能提供一个deleteQuery的示例吗?CakePHP文档似乎缺少任何使用示例。