首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >更新时的Mysql错误

更新时的Mysql错误
EN

Stack Overflow用户
提问于 2016-08-25 10:12:08
回答 4查看 50关注 0票数 1

Error如下所示:

在“where子句”中未知列“辞职_id=‘158’”

UPDATE pr_temporary_absconding_checklists SET completion_status = 'pending' WHEREresignation_id='158' AND checklist_id='4'

我的模型代码是:

代码语言:javascript
复制
function submit_absconding_checklist($post_array, $idss) {

  $this->load->database();
  $ids = $this->uri->segment(4);
  $where = "resignation_id='$ids' AND checklist_id='$idss'";
  $this->db->where($where);
  $dbdata = array(
    "completion_status" => $post_array['completion_status']
  );

  $this->db->update('pr_temporary_absconding_checklists', $dbdata);
  print_r($query);
  die;
  /**
   * if required add this code here to check
   *
   * echo $this->db->last_query();
   */
  return 'Checklist updated successfully';
}

还附上表格图像

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2016-08-25 10:22:19

您可以将查询以活动记录格式写成

代码语言:javascript
复制
$this->db->set("completion_statuscompletion_status", $post_array['completion_status']);
$this->db->where("resignation_id", $ids);
$this->db->where("checklist_id", $idss);
$this->db->update("pr_temporary_absconding_checklists");
$afftectedRows = $this->db->affected_rows();
票数 1
EN

Stack Overflow用户

发布于 2016-08-25 10:15:26

删除查询中resignation_id='158'周围的回退。

它应该是这样的:

代码语言:javascript
复制
UPDATE `pr_temporary_absconding_checklists` SET `completion_status` = 'pending' WHERE `resignation_id`='158' AND `checklist_id`='4'

模型代码:

代码语言:javascript
复制
function submit_absconding_checklist($post_array, $idss) {

  $this->load->database();
  $ids = $this->uri->segment(4);
  $this->db->where('resignation_id', $ids); // UPDATED
  $this->db->where('checklist_id', $idss); // UPDATED
  $dbdata = array(
    "completion_status" => $post_array['completion_status']
  );

  $this->db->update('pr_temporary_absconding_checklists', $dbdata);
  print_r($query);
  die;
  /**
   * if required add this code here to check
   *
   * echo $this->db->last_query();
   */
  return 'Checklist updated successfully';
}
票数 1
EN

Stack Overflow用户

发布于 2016-08-25 10:18:22

试着像这样

代码语言:javascript
复制
$data = array(
    'completion_status' => $post_array['completion_status']
);

$this->db->where('resignation_id', $ids);
$this->db->where('checklist_id', $idss);
$this->db->update('mytable', $data);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39142450

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档