$this->db->replace() 使用哪里

$this->db->replace() using where

我正在尝试在 CodeIgniter 3 中找到与 insert_or_update 类似的内容(类似于 Laravel 提供的内容)。我找到的最接近的是 $this->db->replace(),但我找不到任何指定它 can/can 不能与 ->where() 一起使用的内容。根据文档,我认为这不会起作用,因为它没有将 ->where() 列为一个选项,但我也想仔细检查一下。

我希望我能做类似...

$data = [...];
$whereSearch = [...];
$this->db->replace($data)->where($whereSearch);

这里引用文档的关键是

using PRIMARY and UNIQUE keys as the determining factor.

替换仅基于您的键来替换 table 中的值。您可能会发现 Does replace into have a where clause? 也有帮助。

$this->db->where('column_name',$compared_data); 
$this->db->set('column_name',$updated_data);
$this->db->update('table_name');

这就是您要找的吗?