Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Codeigniter 4软删除仍在删除数据库记录_Php_Codeigniter_Codeigniter 4_Soft Delete - Fatal编程技术网

Php Codeigniter 4软删除仍在删除数据库记录

Php Codeigniter 4软删除仍在删除数据库记录,php,codeigniter,codeigniter-4,soft-delete,Php,Codeigniter,Codeigniter 4,Soft Delete,我对CodeIgniter 4软删除有问题。 我在模型中设置了$useSoftDelete=true;但是每当我删除一条记录时,delete方法总是从我的表中清除它 以下是我的模型中的代码: // Dates protected $useTimestamps = true; protected $useSoftDelete = true; protected $dateFormat = 'datetime'; protected $crea

我对CodeIgniter 4软删除有问题。 我在模型中设置了$useSoftDelete=true;但是每当我删除一条记录时,delete方法总是从我的表中清除它

以下是我的模型中的代码:

    // Dates
protected $useTimestamps        = true;
protected $useSoftDelete        = true;
protected $dateFormat           = 'datetime';
protected $createdField         = 'cust_created_at';
protected $updatedField         = 'cust_updated_at';
protected $deletedField         = 'cust_deleted_at';
以下是我在控制器中的删除方法:

public function delete($id = '')
{
    $customer = $this->customerModel->find($id);
    if (isset($customer)) {
        $this->customerModel->delete($id);
        session()->setFlashdata('success', "Customer $customer->cust_name successfully deleted.");
        return redirect()->to(site_url('customer'));
    } else {
        session()->setFlashdata('errors', ["Cannot find customer ID $id."]);
        return redirect()->to(site_url('customer'));
    }
}
有我漏掉的密码吗? 提前谢谢。

键入
protected$useSoftDelete=true
应该是
protected$useSoftDeletes=true

参考:

你说得对。我使用“PHPSarkMake:model”命令创建模型。它生成$useSoftDelete而不是$useSoftDeletes。非常感谢。