【发布时间】:2012-11-13 06:47:36
【问题描述】:
我尝试通过一键执行更新三个表,但为什么只是 t_user 发生了变化? t_publisher 和 t_label 没有改变并且没有错误警告..
function update($id_user=null){
if (($this->input->post('submit') == 'Update')){
$user=$this->input->post('username');
$pass=$this->input->post('userpassword');
$ussta=$this->input->post('userstatus');
$usty=$this->input->post('usertype');
$id_label = $this->db->query("select ID_LABEL from t_label where LABEL = '$name->USER_NAME'")->row();
$id_publisher = $this->db->query("select ID_PUBLISHER from t_publisher where PUBLISHER = '$name->USER_NAME'")->row();
$data = array(
'USER_NAME' => $user,
'USER_PASS' => $pass,
'USER_STATUS' => $ussta,
'USER_TYPE' => $usty
);
$data2 = array(
'LABEL' => $user,
);
$data3 = array(
'PUBLISHER' => $user,
);
$this->db->where('USER_ID', $this->input->post('id'));
$this->db->update('t_user', $data);
$this->db->where('ID_LABEL', $this->input->post('$id_label'));
$this->db->update('t_label', $data2);
$this->db->where('ID_PUBLISHER', $this->input->post('$id_publisher'));
$this->db->update('t_publisher', $data3);
redirect("registrasi/reg");
}
$var['data'] = $this->db->query("select * from t_user where USER_ID= '$id_user'")->row_array();
$this->load->view('update', $var);
}
请帮忙:)
【问题讨论】:
-
第一个查询中的 ID_LABEL 来自哪里?
-
为什么不使用 echo $this->db->last_query() 一步一步检查它;
-
t_label 上的 id_label.. 我朋友昨天做了..
-
确保您的选择查询正在运行 echo $this->db->last_query()
标签: sql codeigniter sql-update