我可以在codeigniter中使用$this->db->insert_id();
获取最后插入的id,有什么方法可以获取最后更新记录的id吗?我用同样的方法进行了尝试,即 $this->db->insert_id();
但它不起作用(而是返回 0)。
最佳答案
Codeigniter 不支持这一点。我必须这样做:
$updated_id = 0;
// get the record that you want to update
$this->db->where(array('vrnoa'=>$data['vrnoa'], 'etype' => 'sale'));
$query = $this->db->get('StockMain');
// getting the Id
$result = $query->result_array();
$updated_id = $result[0]['stid'];
// updating the record
$this->db->where(array('vrnoa'=>$data['vrnoa'], 'etype' => 'sale'));
$this->db->update('StockMain',$data);
关于php - 获取最后更新记录的id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20310298/