当我检查project_id
时,记录也没有删除。我想删除已指定project_id和beneficiary_id的特定记录。此代码仅适用于beneficiary_id检查
**In model**
public function get_real_beneficiary($id,$project_id) {
$this->db->select('*');
$this->db->from('projects_beneficiaries');
$this->db->where('beneficiary_id', $id);
//$this->db->where('project_id', $project_id);
$query = $this->db->get();
echo $this->db->last_query();
if ($query->num_rows() > 0) {
return $query->row();
}
else return FALSE;
}
public function delete_beneficiary($id) {
$sa = $this->ion_auth->in_group(array(ROLE_SUPERADMIN));
$ad = $this->ion_auth->in_group(array(ROLE_ADMINISTRATOR));
$ma = $this->ion_auth->in_group(array(ROLE_PROJECT_MANAGER));
/* Verify */
if($sa || $ad || $ma){
return $this->db->delete('projects_beneficiaries', array('id' => $id));
}
else return FALSE;
}
**In controller-delete action**
public function delete($id){
$bn = $this->Beneficiaries_model->get_real_beneficiary($this->uri->segment(4),
$this->uri->segment(5));
// log_message('error',$bn->project_id );
$this->Beneficiaries_model->delete_beneficiary($bn->id);
// log_message('error','Project Id:'$this->uri->segment(5) );
redirect('projects/view/' . $this->uri->segment(5));
}
beneficiary_id
出现在不同的项目中。如果我没有检查project_id
所有相关项目
记录正在删除。如何删除指定的记录?
答案 0 :(得分:0)
这里的问题是我没有得到当前的project_id.Now我能够从view中获取项目ID。感谢那些试图帮助我的人。