【发布时间】:2018-06-25 21:26:49
【问题描述】:
大家好,我正在尝试使用 codeigniter 更新表格列,这是我下面的代码。
控制器:
function search2()
{
if ($_POST) {
$Interno=$_POST['Interno'];
}else{
$Interno = '';
}
$this->db->select('empleados.Interno, empleados.Curp, empleados.Nombre, empleados.A_Paterno, empleados.A_Materno, cuentas.Clabe, cuentas.Banco, cuentas.Observaciones, cuentas.Status');
$this->db->from('empleados');
$this->db->join('cuentas',"cuentas.Interno = empleados.Interno AND cuentas.Status !='I'", 'Left');
$this->db->where('empleados.Interno', $Interno);
$q = $this->db->get();
$data = array();
$data['records'] = $q->result_array();
$this ->load -> view('main/indice', $data);
}
function update_Status()
{
$Interno= $this->input->post('Interno');
$data = array(
'Status' => $this->input->post('Inactivo')
);
if($this->consultas_M->update_Status($Interno, $data))
{
echo " update successful...";
}
else
{
echo "update not successful...";
}
}
使用函数 search2,我显示两个表的结果(这可能是问题所在)然后我想将表 cuentas 的状态更改为“I”(不活动,默认为“A”活动)。所以我只想更新那个状态栏。但它什么也没做。 这是我的模型
function update_Status($Interno,$data)
{
$this->db->where('Interno', $Interno);
$this->db->update('cuentas', $data);
}
'Interno' 是表中的 id,也是显示该 id 的输入名称。 任何帮助将不胜感激
【问题讨论】:
-
你有什么错误吗?
-
你的表更新了吗?
-
不,它没有,它将我发送到 else 条件,“更新不成功...”,我检查了 mysql,并且字段没有被更新
-
使用控制器中的
print_r($data);和$Interno确保$data不为空 -
是的,两个都是空的
标签: php mysql codeigniter codeigniter-3