Codeigniter $this->;db->;使用where替换()
我试图在CodeIgniter 3中找到一些类似于插入或更新(类似于Laravel提供的)的东西。我找到的最接近的是Codeigniter $this->;db->;使用where替换(),codeigniter,codeigniter-3,query-builder,Codeigniter,Codeigniter 3,Query Builder,我试图在CodeIgniter 3中找到一些类似于插入或更新(类似于Laravel提供的)的东西。我找到的最接近的是$this->db->replace(),但我找不到任何指定它可以/不能与->where()一起使用的内容。根据文档,我不相信这会起作用,因为它没有将->where()列为选项,但我想再次检查一下 我希望我能做点像 $data = [...]; $whereSearch = [...]; $this->db->replace($data)->where($wher
$this->db->replace()
,但我找不到任何指定它可以/不能与->where()一起使用的内容。根据文档,我不相信这会起作用,因为它没有将->where()
列为选项,但我想再次检查一下
我希望我能做点像
$data = [...];
$whereSearch = [...];
$this->db->replace($data)->where($whereSearch);
这里引用文档的关键是
使用主键和唯一键作为决定因素
“替换”仅基于键来替换表中的值。你可能也会觉得很有帮助
$this->db->where('column_name',$compared_data);
$this->db->set('column_name',$updated_data);
$this->db->update('table_name');
这就是你要找的吗?我不这么认为。我想要一个函数调用来确定是执行insert
还是update
。replace()
函数似乎是一个可行的选项,但我需要它的数据在此实例中没有所需的键。