我正在尝试使用codeigniter更新数据库中的特定列,问题是由于某种原因我无法获取要更新的“ ID”,它说是空的,但是我不知道找不到问题。有没有斗篷的英雄吗? 这是我的控制器:
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');
$Status = $this->input->post('Inactivo');
$data['status'] = ! empty($Status) ? $Status : 'I';
if ( ! empty($Interno))
{
$updated = $this->consultas_M->update_Status($Interno, $data);
if($updated)
{
echo " update successful...";
}
else
{
echo "update not successful...";
}
}
else
{
echo "Interno not found ...";
}
}
这是我的模特
function update_Status($Interno,$data)
{
$this->db->where('Interno', $Interno);
return $this->db->update('cuentas', $data);
if ( $this->db->affected_rows() > 0 )
{
return TRUE;
}
else
{
return FALSE;
}
}
这是视图:
<form action="<?php echo base_url();?>index.php/Datos/validaclabe" method="post" class="form-inline form-responsive">
<div class="form-group">
<br>
<?php
foreach ($records as $row) {
echo"<br></br>";
echo "<label class='control-label'>Interno</label>";
echo "<input type='number' id='Interno' name ='Interno' class='form-control Input col-sm-3' value='".$row['Interno']."'>";
echo "<label class='control-label'>CURP</label>";
echo "<input type='text' id='curp' name ='curp' class='form-control Input col-sm-3' placeholder='Curp' value='".$row['Curp']."'>";
echo "<label class='control-label'>nombre</label>";
echo "<input type='text' id='nombre' name ='nombre' class='form-control Input col-sm-3' placeholder='Nombre' value='".$row['Nombre']."'>";
echo "<label class='control-label'>Apellido Paterno</label>";
echo "<input type='text' id='A_Paterno' name ='A_Paterno' class='form-control Input col-sm-2' placeholder='Apellido Paterno' value='".$row['A_Paterno']."'>";
echo "<label class='control-label'>Apellido Materno</label>";
echo "<input type='text' id='A_Materno' name ='A_Materno' class='form-control Input col-sm-1' placeholder='Apellido Materno' value='".$row['A_Materno']."'>";
echo "<label class='control-label'>Clabe</label>";
echo "<input type='text' id='Clabe' name ='Clabe' class='form-control Input col-sm-3' placeholder='' value='".$row['Clabe']."'>";
echo "<label class='control-label'>Banco</label>";
echo "<input type='text' id='Banco' name ='Banco' class='form-control Input col-sm-2' placeholder='' value='".$row['Banco']."'>";
echo "<label class='control-label'>Observaciones</label>";
echo "<input type='text' id='Observaciones' name ='Observaciones' class='form-control Input col-sm-1' placeholder='' value='".$row['Observaciones']."'>";
echo "<input type='hidden' id='Status' name ='Status' class='form-control Input col-sm-1' value='".$row['Status']."'>";
}
?>
<input type="hidden" id="Inactivo" name="Inactivo" value="I" placeholder="I">
</div>
<div class="" align="rigth">
<button type="submit" id="actualizar" name="actualizar" class="btn btn-primary active" onclick ="return validacion()">Nueva Cuenta</button>
<a href="<?php echo base_url();?>index.php/Datos/update_Status" id="Desactivar" name="Desactivar" class="btn btn-danger" onclick="return val2()">Desactivar Cuenta</a><span id="msg"></span>
</div>
当我尝试进行更新时,它使我进入其他第二个条件,其中说“找不到Interno”(Interno是ID),我不知道为什么找不到它。 再次感谢您的提前帮助!