php - mysql更新时出错

标签 php mysql codeigniter web-applications codeigniter-2

错误 看起来像这样:

Unknown column 'resignation_id='158'' in 'where clause'

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

我的模型代码是:

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';
}

另附表图 enter image description here :

最佳答案

您可以将查询以 Active Record 格式编写为

$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();

关于php - mysql更新时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39142450/

相关文章:

mysql - 如何在 MYSQL 中使用 if 查询创建虚拟列

mysql - Codeigniter 和 MYSQL 日期时间

php - Mysql错误: Duplicate entry '1-5' for key 'PRIMARY' on insert unsure of how

php - Paypal 支付数据传输 (PDT) 错误 4002

php - PHP PDO如何在注册时对密码进行哈希处理,然后在登录时“取消哈希处理”

php - 抽象类无法实现? (PHP 5.2.9)

php - 对 mysql 结果进行排序,使特定 id 排在第一位

mysql - SQL : replace string with value from a field (bulk edit)

php - 我从 $path-open cart 2 中删除 "$_SERVER[' SCRIPT_FILENAME'] "后,网址无法正常工作

php - 通过php、mysql脚本将大量记录(大约40,000条)插入到mysql中