【发布时间】:2011-12-22 15:59:40
【问题描述】:
我使用的是 codeigniter 2.0.3 版。我正在尝试使用
获取更新查询后受影响的行数$this->db->affected_rows
即使没有更新任何行,它也总是返回 1。我试过了
mysql_affected_rows()
如果查询失败,则返回 -1,如果没有更新记录,则返回 0。
编辑包括我的代码
我只是在使用
$country_id = $this->input->post('country_id');
$time=$this->input->post('time');
$insert_array = array(
'country' => $this->input->post('name')
);
$this->db->update('country_master', $insert_array, array("country_id" => $country_id,"last_updated"=>$time));
$afftectedRows=$this->db->affected_rows();
【问题讨论】:
-
您介意展示您的代码吗?
-
这取决于您在 $this->db->affected_rows 之前使用的查询,如果您可以显示您的代码,那么共享解决方案将很容易。
-
嗯,这是我的错误。它现在工作正常
标签: codeigniter