gpt4 book ai didi

CakePHP 1.3 替代 SoftDeletable 行为?

转载 作者:行者123 更新时间:2023-12-04 23:31:30 26 4
gpt4 key购买 nike

有谁知道 的替代品吗? SoftDeletable Behavior 兼容蛋糕 1.3.x ?

如果没有任何现成的行为可用,有关我如何在最新的 Cake 中执行此操作的任何建议?

想出了一个快速的黑客。首先,如果您的表引入了 tinyint(1) 无符号 名为 的字段已删除 默认为 0 .

app/app_model.php , 添加如下函数:

function softDelete( $id ) {
if( $id && $this->hasField( 'deleted' ) ) {
$this->id = $id;
return $this->saveField( 'deleted', 1 );
}

return false;
}

然后从您的 Controller 方法(执行删除)调用,
$this->Model->softDelete( $id );

Catch is, 无论你在哪里表演 查找() ,需要指定条件 删除 != 1 .

仍在试图弄清楚如何以与 SoftDeletable 行为相同的方式实现这一点。

最佳答案

我已将 mariano 的行为调整为 1.3。看这里 - https://github.com/evilbloodydemon/cakephp-softdeletable2

关于CakePHP 1.3 替代 SoftDeletable 行为?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4468229/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com