dongzhang8680 2014-01-21 07:15
浏览 57
已采纳

Where子句在PHP代码中不起作用[关闭]

When I am checking project_id also record is not deleting.here i want to delete a particular record which has specified project_id and beneficiary_id.This code is working only for beneficiary_id checking

 **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 is present for different projects.If I am not checking project_id all related records are deleting. How can I delete specified record?

  • 写回答

1条回答 默认 最新

  • douchenbiao0916 2014-01-22 05:09
    关注

    here the problem is i am not getting current project_id.Now i am able to get the project id from view.Thank you who tries to help me.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程